CHAPTER 9

 < Day Day Up > 



  1. The code segments for generation of ASK and FSK signals are given in Listing C.4. The screen shots are given in Figure C.5 and Figure C.6.

Listing C.4: Generation of ASK and FSK waveforms.

start example
 /* To draw ASK waveform for 1 kHz tone */ void CSendDialog::ASKPlotter() {    int n, j1, j2, var=0, mm=0;    int i=0, xr[8], bit;    char c;    wn=8*0.01745 ;    CWindowDC dc(GetDlgItem(IDC_SINE));    LOGBRUSH logBrush;    logBrush.lbStyle =BS_SOLID;    logBrush.lbColor=RGB(0,255,0);    CPen pen(PS_GEOMETRIC | PS_JOIN_ROUND,1, &logBrush);    dc.SelectObject(&pen);    dc.SetTextColor(RGB(255,255,255));    CString strData;    strData="My Sample Text";    for(int ii=0;ii<strData.GetLength();ii++)    {       c = strData[ii];       dc.TextOut(20,10,"Amplitude1 = ±1V");       dc.TextOut(20,30,"Amplitude2 = ±2V");       dc.TextOut(150,10,"Freq = 1200Hz ");       var=0;       xs=0;ys=0;       for(j2=0,i=0;j2<8;j2++){             bit=c%2;             xr[i]=bit;             i=i+1;             c=c/2;       }       for(i1=0;i1<=360;i1++){             ya[i1]=amp1*sin(wn*i1);             yb[i1]=amp2*sin(wn*i1);       }       for(n=0;n<8;n++){             if(xr[i-1]==1){                   PlotSine1(&dc, var);i---;             }             else{                   PlotSine2(&dc, var);i---;             }             var=var+45;          }          incr=0;          _sleep(200);          CRect rect;          m_sine.GetClientRect(rect);          dc.FillSolidRect(rect, RGB(0,0,0));       }// End For str.Length          m_start.SetWindowText("Send Code");    }    /* To draw the sin waveform when signal is present */    void CSendDialog::PlotSine1(CWindowDC *dc, int var)    {       if(incr!=0)          incr-=1;       flagctrl=1;       line(*&dc,25,110,385,110);       for( i1=var; i1<=var+45; i1=i1+1 )       {          xe=i1; ye=ya[i1];          spect[incr+=1]=ya[i1];          line(*&dc, 25+xs, 110-ys, 25+xe, 110-ye );          xs=xe;          ys=ye;       }    }    /* To draw the sin waveform when signal is not present */    void CSendDialog::PlotSine2(CWindowDC *dc, int var)    {       if(incr!=0)          incr-=1;       line(*&dc,25,110,385,110);       for( i1=var; i1<=var+45; i1=i1+1 )        {           xe=i1; ye=yb[i1];           spect[incr+=1]=yb[i1];           line(*&dc, 25+xs, 110-ys, 25+xe, 110-ye);           xs=xe;           ys=ye;        }        flagctrl=0;    }    /* To draw the horizontal line */    void CSendDialog::line(CWindowDC *dc, short x1, short y1, short x2, short y2)    {       dc->BeginPath();       dc->MoveTo(x1,y1);       dc->LineTo(x2,y2);       dc->CloseFigure();       dc->EndPath();       dc->StrokePath();    }    /* To draw FSK waveform for 1 kHz tone */    void CSendDialog::FSKPlotter()    {       int n, j1, j2, var=0;       int i=0, xr[1000], bit;       char c;       wn1 = 8*0.01745 ;       wn2 = 32*0.01745;       CWindowDC dc(GetDlgItem(IDC_SINE));       LOGBRUSH logBrush;       logBrush.lbStyle = BS_SOLID;       logBrush.lbColor = RGB(0,255,0);       CPen pen(PS_GEOMETRIC | PS_JOIN_ROUND, 1, &logBrush);       dc.SelectObject(&pen);       dc.SetTextColor(RGB(255,255,255));       CString strData;       strData="My Sample Text";       for(int ii=0;ii<strData.GetLength();ii++)       {          c=strData[ii];          dc.TextOut(20,10,"Freq1 = 1200Hz");          dc.TextOut(20,30,"Freq2 = 2000Hz");          var=0;          xs=0;          ys=0;          for(j2=0,i=0;j2<8;j2++){                bit=c%2;                xr[i]=bit;                i++;                c=c/2;          }          for(i1=0;i1<=360;i1++){                ya[i1] = amp1*sin(wn1*i1);                yb[i1] = amp1*sin(wn2*i1);          }          for(n=0;n<8;n++){                if(xr[i-1]==1){                      PlotSine1(&dc, var);i---;                }else{                      PlotSine2(&dc, var);i---;                }                var = var + 45;          }          incr=0;          _sleep(200);          CRect rect;          m_sine.GetClientRect(rect);          dc.FillSolidRect(rect, RGB(0,0,0));    } } 
end example

Figure C.5 shows a screenshot for ASK waveform for data.

click to expand
Figure C.5: ASK waveform.

Figure C.6 shows a screenshot of an EFSK waveform.

click to expand
Figure C.6: FSK waveform.

  1. The code segment for generation of a 1kHz sine wave is given in Listing C.5. You can use this as the modulating signal to generate the modulated signals. The waveform is shown in Figure C.7.

Listing C.5: To generate a 1KHz sine wave.

start example
 /* To Display the signal on the screen*/ void CSingleToneDlg::Tone(int i) {    CWindowDC dc(GetDlgItem(IDC_SINE));    CRect rcClient;    LOGBRUSH logBrush;    logBrush.lbStyle =BS_SOLID;    logBrush.lbColor=RGB(0,255,0);    CPen pen(PS_GEOMETRIC | PS_JOIN_ROUND,1, &logBrush);    dc.SelectObject(&pen);    dc.SetTextColor(RGB(255,255,255));    while(continueThread){       m_sine.GetClientRect(rcClient);       dc.FillSolidRect(rcClient, RGB(0,0,0));       dc.MoveTo(0,rcClient.bottom/2);       int x, y;       dc.MoveTo(0,rcClient.bottom/2);       for (x =0 ; x < (rcClient.right); x++) // display Input       {            y    = rcClient.bottom/2   - ToneNextSample();            dc.LineTo(x, y);       }       Sleep(200);    } } /* To initialize the frequency*/ void CSingleToneDlg::ToneInitSystem(double Freq) {    T2PI = 2*TPI;    TSampleNo = 0;    ToneFreq = Freq;    TWT = ToneFreq*0.000125;    TWTn = 0;    TSampleNo = 0; } /* To calculate the next sample value */ int CSingleToneDlg::ToneNextSample() {    int TISample;    double TSample;    int c;    TSampleNo++;    TSample = KTONE_AMPL*sin(T2PI*TWTn);    TWTn += TWT;    if (TWTn > 1.0) TWTn -= 1.0;    TISample = (int) TSample;    return TISample; } 
end example

Figure C.7 shows a 1kHz sine wave.

click to expand
Figure C.7: 1kHz sine wave.

  1. Comparison of modulation techniques is done based on the noise immunity, bandwidth requirement, error performance, and implementation complexity of the modulator/demodulator. ASK is not immune to noise. QPSK occupies less bandwidth, but implementation is complex. The waterfall curve given in the Chapter 10 gives the performance of different modulation techniques.

  2. The modems used in radio systems are called radio modems, and the modems used on wired systems are called line modems. GSM and Bluetooth are radio systems. The modulation used in GSM is GMSK. Bluetooth uses Gaussian FSK. There are various standards for line modems specified by ITU. These are V.24, V.32, V.90, and so on.

  3. If the bandwidth of the modulating signal is 20kHz, the bandwidth of the amplitude-modulated signal is 40kHz.

  4. If the bandwidth of a modulating signal is 20kHz and the frequency deviation used in frequency modulation is 75kHz, the bandwidth of the frequency modulated signal is 2(20 + 75) kHz = 190kHz.



 < Day Day Up > 



Principles of Digital Communication Systems and Computer Networks
Principles Digital Communication System & Computer Networks (Charles River Media Computer Engineering)
ISBN: 1584503297
EAN: 2147483647
Year: 2003
Pages: 313
Authors: K V Prasad

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net