--What's there in the floppy?

The floppy contains source code for the various assignments mentioned in
this book. It also contains the executable files of these source codes.
Along with the executables there is one utility program called 'SHOW'
which can be used to display the files of samples generated by various
programs in the assignments.

--Structure of the floppy:

A:\source => source codes for the assignments.
A:\execs => executables for the assignments and SHOW utility.

I am assuming that your floppy 1.44 M floppy drive is designated as
A drive.

--System requirements.
PC 386 and Above, with 640KB of main memory.
Monitor and PCIVGA card supporting 640 x 480 resolution.

--How to use the executables:

1. generate.exe
This program is used to generate samples of 6 types of signals namely,
Sine, Cosine, Square, Random, Exponential, and Sawtooth.
The samples are generated using the mathematical expressions for the above
signals.
The Program takes in Type of the signal as input. It then asks for
parameters such as sampling frequency, frquency of the signal etc.
After taking these inputs it generates 500 samples of the signal
and stores them in a fil, name of which is input by the user.
The file can be viewed by using the utility program SHOW.
To get good results normally sa,pling frequency sholud be at least 8
times frequency of the signal.


2. Diffeq.exe
This program is used to calculate the output of a system, which is
described by the linear difference equation,
y(n) = a0 * x(n) + a1 * x(n-1) + a2 * x(n-2) + .... + aP * x(n-P)
        + b1 * y(n-1) + b2 * y(n-2) + .... + bQ * y(n-Q)
where y(n) and x(n) represent current output and input respectively.
The user has to input the a coefficients and the y coefficients.
The input siganl to the system can be from the file or from the console.
The output is written to the file DiffEq.txt which can be seen using the
utility SHOW.


3. Convolve.exe
This program is used to convolve two signals input from the console
by the user or raed from two files name which can be input from the user.
The maximum length of the siganls is limited to 25 but it can be increased
easily  by incresing the memory allocated to store the samples of the
signals to be convolved and the convolved output.
The program also asks the user to input the starting point for the two input
signals and pads adequate number of zeros if starting point is greter then
the length of the signal.
The program starts the convolution from appropriate point according to the
starting points for the two signals.
The output is stored in the default output file, Conv.txt, which can be
viewed using the SHOW utility.


4. Fourier.exe
This program is used to calculate the fourier transform of the signal at
a particular frequency input by the user.
The formula used is,
        X(w) =   x(n) * e^(-j*w*n)
The value of w varies from 0 to Pi, and is input from the user.
Teh signal of which the fourier transform is calculated can be input
from the console or the file.


5. Ztrans.exe
This program is used to calculate the Z transform of a sequence.
The user has to input the length of the sequence and the values. the user
has to input the starting point also.
The Z tranform is calculated as,
        H(z) =  h(n) Z^-n


6. Coef2plt.exe
This program is used to calculate the poles and zeros of the system
from the coefficients of the difference equation of the system are given.
The difference equation is given as,
y(n) = a0 * x(n) + a1 * x(n-1) + a2 * x(n-2) + .... + aP * x(n-P)
        + b1 * y(n-1) + b2 * y(n-2) + .... + bQ * y(n-Q)
where y(n) and x(n) represent current output and input respectively.

The user has to input the values P and Q-1 (b0 doesn't exist) and the
corrosonding a and b coefficient values.
The program can also read above values from the default coefficient file
coeff.dat.

After reading the coefficients the program generates the polynomials of Z
from the system function given as,

        a0 + a1 * Z^-1 + a2 * Z^-2 + a3 * Z^-3 + .... + aP * Z^-P
H(Z) = --------------------------------------------------------------
         1 + b1 * Z^-1 + b2 * Z^-2 + b3 * Z^-3 + .... + bQ * Z^-Q

These polynomials in Z are solved using LinBairstow method of obtaining
roots of the polynomial to get the position of poles and zeros in terms
of real and imaginary components.

The Advantage of LinBairstow method is that it can calculate roots of
the polynomial as both real and imaginary numbers.

The poles and zero's thus obtained can be plotted on the Z plane.


7. Xferfn.exe
This program is used to calculate magnitude and phase plots for the
given coefficients of a system.
The system function in Z domain is given as,

        a0 + a1 * Z^-1 + a2 * Z^-2 + a3 * Z^-3 + .... + aP * Z^-P
H(Z) = --------------------------------------------------------------
         1 + b1 * Z^-1 + b2 * Z^-2 + b3 * Z^-3 + .... + bQ * Z^-Q

The coefficients are read from the default coefficient file coeff.dat.


8. plz2cff.exe
This is a program for filter design using pole zero placement.
The program accepts the pole zero locations in terms of magitude r
in the Z plane and angle in radians.
The program then calculates the filter coefficients by first performing
all the cross products for the Z terms, and then coverting them to the
system transfer function in Z domain.
The coefficients are written to the default coefficient file coeff.dat


9. Notch.exe
This program is used to design a notch filter with a notch at the given
frequency.
The notch filter is obtained by placing a zero on the unit circle at the
desired frequency.
The frequency is input by the user along with the sampling frequency.
The fiter coefficients are written to default coefficient file coeff.dat


10. Lpf.c
This program is used to design Low Pass FIR filter with given cutoff
and sampling frequency.
The user has to input the sampling frequency, cutoff frequency, Number
of coefficients for the filter, and the window function to be applied
to the filter coefficients.


11. hpf.c
This program is used to design High Pass FIR filter with given cutoff
and sampling frequency.
The user has to input the sampling frequency, cutoff frequency, Number
of coefficients for the filter, and the window function to be applied
to the filter coefficients.
The program is same as lpf.c only equation is different.


12. Bilinear.c
This program is used to design an IIR filter by using bilinear
transformation method. 
In this program the filter designed is 2nd oder filter.
In biliner transformation the transfer function of the filter in
S domain (Laplace variable S) is given. The corrosponding transfer
function in Z domain is obtained by replacing S by
            2 (1 - Z^-1)
            ------------
            T (1 + Z^1 )
2/T is a factor depending on the resonant fequency of the filter.
You have to input the values of a and b in the following equation
                       s + a
         H(s) =  ------------------ 
                  (s + a)^2  +  b

from which the factor 2/T is derived.


13. SHOW.exe
Usage: on the command prompt,
        SHOW <filename>
where,
Filename is the name of the file to be viewed.
This file can be signal files generated using above progarms or any
user file compatible to the file format given below.


--When you compile and run the source code make sure that the file EGAVGA.BGI
is in the same dirctory. This file is present in the exes dirctory.
I have used TurboC compiler to compile and run the programs.

--Format of the coeff.dat file:
Number of 'a' coefficients (Multiplied to the input samples)
Number of 'b' coefficients (Multiplied to the output samples)
'a' coefficients,
a0
a1
a2
...
aP

'b'coefficients,
b1
b2
...
bQ.


--Format of the file accepted by SHOW utility:
FileTag : NGPFile&
Number of signals (Integer <= 3 and > 0)
Distance between two samples on x axis (integer > 0 and < 6)
Number of samples (Integer <= 500)
Maximum value the samples can take (Float < 1.0e10)
Minimum value the samples can take (Float > -1.0e10)
Tag for X axis (Any string length < 6)
Tag for Y axis (Any string length < 6)
Samples
Signal0  Siganl1  Signal2
smpl0    smpl0    smpl0
smpl1    smpl1    smpl1
smpl2    smpl2    smpl2
smpl3    smpl3    smpl3
....
smplN    smplN    smplN
where,
N = Number of sample - 1
