1. (a) GENERATION OF AM, DSBSC & SSB-SC WAVES AIM: To generate amplitude modulated, double side band and single side band suppressed carrier using MAT LAB Program. EQUIPMENT REQUIRED: 1. Personal Computer With MATLAB 2007 r 1. AMPLITUDE MODULATION FORMULA Vm(t) = Vm Sin ωmt Vc(t) = Vc Sin ωct Vam = Vc + Vm = Vc(1+Vm/Vc sin ωmt) Vam = Vc(1+Ma Sin ωmt) Instantaneous amplitude of modulated signal is Vam(t) = Vc Sin ωct + maVc/2 cos(ωc- ωm)t - maVc/2 * cos(ωc+ ωm)t Where, Vm- amplitude of modulating signal Vc – amplitude of carrier signal Vam – amplitude of carrier signal after modulation Ma – modulation index Wm –angular frequency of modulating signal Wc – angular frequency of carrier signal Vam (t) – amplitude modulated signal ALGORITHM: Read the amplitude and frequency of message and 1
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
1. (a) GENERATION OF AM, DSBSC & SSB-SC WAVES
AIM:
To generate amplitude modulated, double side band and single side band suppressed carrier using MAT LAB Program.
EQUIPMENT REQUIRED:
1. Personal Computer With MATLAB 2007 r
1. AMPLITUDE MODULATION
FORMULA
Vm(t) = Vm Sin ωmt
Vc(t) = Vc Sin ωct
Vam = Vc + Vm = Vc(1+Vm/Vc sin ωmt)
Vam = Vc(1+Ma Sin ωmt)Instantaneous amplitude of modulated signal is
Vm- amplitude of modulating signalVc – amplitude of carrier signalVam – amplitude of carrier signal after modulationMa – modulation indexWm –angular frequency of modulating signalWc – angular frequency of carrier signalVam (t) – amplitude modulated signal
ALGORITHM:
Read the amplitude and frequency of message and carrier signal
Generate message and carrier signals for the assigned time intervals
Plot the message and carrier signal
Calculate the lower side band and upper side band frequency of the
spectrum and generate the amplitude modulated signal
End the execution of the program
1
2. DOUBLE SIDE BAND SUPPRESSED CARRIER:
FORMULA:
Let the modulating signal be ,Vm(t) = vm Sin wmt
Let the carrier signal be,Vc (t) = vc sin wct
DSb-sc signal = Vm (t)* Vc(t)
ALGORITHM:
Start the execution of the program
Read the amplitude and frequency of message and carrier signal
Generate message and carrier signals for the assigned time intervals
Calculate the lower side band and upper side band frequency of the
spectrum and generate the Double side band suppressed carrier
signal
Plot the DSB-SC signal waveform
End the execution of the program
3. SINGLE SIDE BAND SUPPRESSED CARRIER:
ALGORITHM:
Read the sampling frequency ‘ fs‘ and time interval ‘t’
Generate sin wave (message signal) for a fixed frequency
Plot the message signal in time domain and frequency domain
Modulate the message signal for the given carrier frequency and
plot it in the frequency domain
Demodulate the modulated signal to obtain the message signal and plot it
• Get the samples of the input frequency signal at 35 kHz• Get the sample rate values• Load the auxiliary register ARO with factor 4• Perform the convolution of the samples of filter co efficient• The output of the fir filter is sent out of the DAC once every 4 outputs• Next data is loaded in DAC after convolution and send out after next 4 sample
Interpolation:• Get the samples of the input frequency signal at 35 KHZ at lower sampling rate• Load the filter co efficient from program memory location• Move the filter co efficient from program memory location to data memory location• Find convolution of input data with the filter co efficient• The output is increased by a factor 4
BLOCK DIAGRAM FOR DECIMATION
FLOW CHART DECIMATION:
16
PROGRAM FOR DECIMATION
Program description:
In this program the sampling rate at the input is 35 KHz. This input sampling rate is reduced by a factor of 4 at the output. For this, the auxiliary register AR0 is loaded with the value of 4 initially. Then the output of the FIR filter is sent out to the DAC only once out of 4 outputs. i.e. when ever the register AR0 becomes 0, the filter output is sent to the DAC and reloaded with 4. Where 4 is the decimation factor of this decimator.
Approximation type: Window design - Rectangular WindowFilter type: Low pass filterFilter Order: 52Cutoff frequency in KHz = 4.000000
RPT #33HMACD 0FF00H,*-APACLAR AR1,#0300HSACH * ;give as sach *,1 incase of overflowLACC *ADD #800HSFR ;remove if o/p is less amplitudeSACL *
MAR *,AR0BANZ NO_OUT,*-
MAR *,AR1OUT *,4LAR AR0,#4H
NO_OUT:LACC #0FFH
SACL 0OUT 0,05NOPB ISR.end
BLOCK DIAGRAM FOR INTERPOLATION
FLOW CHART INTERPOLATION:
20
PROGRAM FOR INTERPOLATIONPROGRAM DESCRIPTION:
In this program the sampling rate is increased at the input by including zeros. The samples are taken at the lower sampling rate and since this program uses the interpolation factor of 4, three zeros are included after each sample taken from the ADC. So the number of samples and thus the sampling rate is also increased.
; LAR AR7,#0 ;change value to modify sampling freq.; MAR *,AR7;BACK: BANZ BACK,*-
RPT #10HIN 0,4LAR AR0,#4HB STORE
INC0: SPLK #0H,0HRPT #15H
NOPSTORE: NOP
NOPNOPNOPMAR *,AR1
23
LAR AR1,#0300HLACC 0AND #0FFFHSUB #800HSACL *LAR AR1,#333HMPY #0ZACRPT #33HMACD 0FF00H,*-APACLAR AR1,#0300HSACH * ;give as sach *,1 incase of overflowLACC *ADD #800HSFR ;remove if o/p is less amplitudeSACL *OUT *,4LACC #0FFFHSACL 0OUT 0,05NOPB ISR.end
RESULT:Thus the incoming sine wave with frequency 35 KHZ is decimated and interpolated
by the factor 4
3. QUADRATURE MIRROR FILTERS
24
AIM:
To simulate mirror filters by using MATLAB
EQUIPMENT REQUIRED:
• MATLAB • SIMULINK
THEORY:The basic building block in applications of quadrature mirror filters (QMF) is the two channel QMF bank. This is the multirate digital filter structure that employs two decimators in the signal analysis section and two interpolators in the signal synthesis section and the low pass and highpass filters in the analysis section have impulse response h0(0) and h1(n) respectively. Similarly lowpass and high pass filters contained in the synthesis section have impulse response g0(n) and g1(n) respectively. The scale factor 2 corresponse to the interpolation factor used to normalize the overall frequency response of the QMF. With this choice of the filter characteristics, the component due to aliasing vanishes. Thus the aliasing resulting from decimation in the analysis section of QMF bank is perfectly cancelled by the image signal spectrum that arises due to interpolation. As a result, two channels QMF behaves as a linear time invariant system.
RESULT :Thus by using the above theory the QMF has been simulated using MATLAB filters
Packages
4. IMPLEMENTATION OF LINEAR AND CYCLIC CODES
26
AIM:To implement a cyclic code generator and syndrome calculator and to verify the same for the given polynomial
EQUIPMENT REQUIRED:• IC 7495• IC 7486• Trainer kit• Connectivity wires
THEORY:Cyclic code:
Cyclic code from a subclass of linear block codes an advantage of cyclic code over most other types of codes is that are easy to encode further more cyclic codes posses a well defined mathematical structure, which has led to the development of very efficient decoding schemes A binary code is said to be a cyclic code if it exhibits two fundamental properties
1.linear property:The sum of two code words is also a code word
2.cyclic property:Any cyclic shift of a code word is also a code word
The gate is switched on hence the M message bits are shifted into channel as soon as the K message bits have entered the shift register, the resulting (n-k) bits in the register from the parity bits The gate is switched OFF there by berating the feedback connection the contents of the shift register are shifted out into the channel the polynomial for the message (1001) is given by g(t).the contents of the shift register are modified by the incoming message bits as in tables, after A shifts the parity bits are (011), according appending these parity bits to the message bits (1001),we get the code word(0111001)
SYNDROME CALCULATOR BLOCK DIAGRAM:
27
SYNDROME CIRCUIT DIAGRAM:
SYNDROME CALCULATOR:
Suppose if the code word (X0,X1,X2,X3………Xn) is transmitted over the noisy channel and received word (Y0,Y1.Y2,Y3……..Yn) the syndrome is calculated for error, if syndrome contain zero there is an error and if non zero is present it contains error.
In case of cyclic code, the received word be represented by polynomial of degree (n-1) as Yn=a(n).g(n) + s(d)S.T. The remainder S(n) is syndrome polynomial of degree n-k-1 or less. Its co-efficients are making up the (n-k) by -1 syndrome S once we know S, we can determine the corresponding error pattern and there by mate the approximate correction.
The cyclic code generation includes the following steps:1. Multiplication of the message polynomial D(x) by X(n-k).2. Division of X(n-k) by D(x) by the generator polynomial G(x) to obtain the remainder.3. Addition of the remainder to X(n-k) D(x) to form the desired code polynomial.
The given polynomial is, G(x) = 1+X+X3
Connect the circuit as shown in the figure for(7,4 cyclic code) So the code word is 011101. The above steps are implemented by means of flip-flops, multipliers, adders, wholly as linear feedback shift register and an external clock control’s the operation of Flipflops.
Let the transmitted code word be (0111001) and the received word (0111001) and the received word (0110001) and the received word be (0110001) that is the middle bits is in error as the received bits are fed into ht shift register initially set to zero its content are modified as in table at the end of seventh shift register as 110. Since the syndrome is non zero the received word is in error pattern corresponding to this syndrome is in the middle bits of the received word.
28
PROCEDURE:CODE GENERATOR:
• Give the message bits and note down the outputs across flipflop P0,P1,P2• As the last message bits is given as the input the required code to be transmitted is get across the flipflop P0,P1,P2• The transmitted message = message + code
CODE GENERATOR BLOCK DIAGRAM:
PIN DIAGRAM OF IC 7495
29
SYNDROME CALCULATOR:• Connect the circuit as shown in the figure• Give the code word as the input to one of the X – OR gate as shown in the figure starting from LSB.note down the output across flipflop S0,S1,S2• At the MSb if the required bit is correct we get zeros across S0,S1,S2 we get error according to the bit corrupted which has to be checked in the table
The cyclic code was designed for generating word where message a = 1001 and parity bitgenerating was 011. The circuit was executed and output table was verified. The syndrome calculator circuit was designed first for the class where no error occurred and if one bit error was occurring both the output flipflop for these cases were verified and observation were written.
31
5. LEXICAL ANALYZER
AIM:To write a C Program to implement a Lexical analyzer.
ALGORITHM:1)Start the program.2)Declare all the variables and file pointers.3 )D i sp l ay t he i npu t p rog ram.4)Separate the keyword in the program and display it.5)Display the header files of the input program.6)Separate the operators of the input program and display it.7 )P r in t t he punc tua t i on marks .8)Print the constant that are present in input program.9)Print the identifiers of the input program.10)Stop the program
RESULT:Thus the above the program is executed and the required output is obtained.
35
6. IMPLEMENTATION OF SEMAPHORES AND MONITORS INCLASSICAL PROBLEMS OF SYNCHRONIZATION
ALGORITHM1) Start2) Define the maximum buffer size.3) Enter the number of producers and consumers.4) The producer produces the job and put it in the buffer.5) The consumer takes the job from the buffer. 6) If the buffer is full the producer goes to sleep.7) If the buffer is empty then consumer goes to sleep.8) Stop
PROGRAM #include<stdio.h>#include<unistd.h>#include<pthread.h>#define buffSize 1000struct{pthread_mutex_tmutex;int buff[buffSize];intproducedCount;intconsumedCount;}shared={PTHREAD_MUTEX_INITIALIZER};void *produce(void *arg);void *consume(void *arg);void main(){intprodThreads,consThreads,i;printf(“\nEnter the no of Producers: “);scanf(“%d”,&prodThreads);printf(“\nEnter the no of Consumers: “);scanf(“%d”,&consThreads);intproducerArr[prodThreads],consumerArr[consThreads];pthread_t producer[prodThreads],consumer[consThreads];pthread_setconcurrency(prodThreads+consThreads);for(i=0;i<prodThreads;i++){producerArr[i]=0;pthread_create(&producer[i],NULL,produce,&producerArr[i]);}for(i=0;i<consThreads;i++){
OUTPUTEnter the no of Producers: 4Enter the no of Consumers: 3ResultThe Producer (0) produced: [252] ItemsThe Producer (1) produced: [415] ItemsThe Producer (2) produced: [136] ItemsThe Producer (3) produced: [197] Items The Consumer (0) Consumed: [703] ItemsThe Consumer (1) Consumed: [260] ItemsThe Consumer (2) Consumed: [37] Items RESULT
Thus the semaphore is implemented and the output is verified for the classical problem ofsynchronization successfully.
38
7. USAGE OF SYSTEM CALLS
ALGORITHM
1) Start2) Define the flags.3) Define the system calls open(), Close(), write(), lseek()&perror()4) Open and close a file using open() and close() function.5) Write the data in to the opened file using write(). 6) Move the cursor by using lseek()..7) Show the error message using perror().8) Stop
PROGRAM
GENERAL CLASS SPECIFIC CLASS SYSTEM CALL --------------------------------------------------------------------- File Structure Creating a Channel creat() Related Calls open()close()Input/Outputread()write() Random Access lseek() Channel Duplication dup() Aliasing and Removing link() Files unlink() File Status stat()fstat() Access Control access()chmod()chown()umask() Device Control ioctl() --------------------------------------------------------------------- Process Related Process Creation and exec() Calls Termination fork()wait()exit() Process Owner and Group getuid()geteuid()
39
getgid()getegid() Process Identity getpid()getppid() Process Control signal()kill()alarm() Change Working Directory chdir() ----------------------------------------------------------------------Interprocess Pipelines pipe() Communication Messages msgget()msgsnd()msgrcv()msgctl() Semaphores semget()semop() Shared Memory shmget()shmat()shmdt() ----------------------------------------------------------------------
if (fd != -1) {printf("file.dat opened for read/write access\n");write(fd, message, sizeof(message));lseek(fd, 0L, 0); /* go back to the beginning of the file */if (read(fd, buffer, sizeof(message)) == sizeof(message))printf("\"%s\" was written to file.dat\n", buffer);elseprintf("*** error reading file.dat ***\n");
40
close (fd); }elseprintf("*** file.dat already exists ***\n");exit (0); }
Lseek()&perror():
#include <stdio.h> #include <fcntl.h>
int main() {intfd;long position;
fd = open("file.dat", O_RDONLY);if ( fd != -1) {position = lseek(fd, 0L, 2); /* seek 0 bytes from end-of-file */if (position != -1)printf("The length of file.dat is %ld bytes.\n", position);elseperror("lseek error"); }elseprintf("can't open file.dat\n");close(fd); }
RESULT
Thus the system calls are implemented and the outputs are verified.