lab report

121
INDEX 8051 MICROCONTROLLER ....................... 3 SWITCH CONTROLLED LED ..................................................................................... 4 INTERRUPT PROGRAMMING ..................................................................................... 5 STEPPER MOTOR INTERFACING ............................................................................... 7 PIC MICROCONTROLLER......................... 9 BIT PATTERN ON PORTC ........................................................................................ 10 Timer Operation........................................................................................................ 12 PWM SIGNAL GENERATION ..................................................................................... 14 ANALOG TO DIGITAL CONVERTER ......................................................................... 16 ARM ...................................................... 18 General Purpose Output Interface ................................................................................ 19 Interfacing with Switch ............................................................................................... 21 ADC Interfacing ........................................................................................................ 23 Timer Interface ......................................................................................................... 24 UART Interfacing ...................................................................................................... 26 LCD Interfacing ........................................................................................................ 28 PSPICE .................................................. 30 CMOS Inverter ......................................................................................................... 31 NAND Gate .............................................................................................................. 32 2:1 Multiplexer.......................................................................................................... 33 4:1 Multiplexer.......................................................................................................... 34 D Latch ................................................................................................................... 36 Full Adder ................................................................................................................ 37 Labview .................................................. 39 Binary to Decimal Conversion ..................................................................................... 40 Odd/Even Number Generation .................................................................................... 42 3 Bit Counter ........................................................................................................... 44 7-Segment Display .................................................................................................... 47 Band Pass IIR Filter ................................................................................................... 50 Rotation of an Array .................................................................................................. 52 MATLAB ................................................ 54 Linear Convolution .................................................................................................... 55 Circular Convolution.................................................................................................. 57 DFT using MATLAB .................................................................................................. 59

Upload: elangovan-sekar

Post on 18-Aug-2015

221 views

Category:

Documents


0 download

DESCRIPTION

ME EMBEDDED SYSTEMS WORKING LAB PROGRAMS FOR THE FIRST SEMESTER ANNA UNIVERSITY.........

TRANSCRIPT

INDEX 8051 MICROCONTROLLER ....................... 3 SWITCH CONTROLLED LED ..................................................................................... 4 INTERRUPT PROGRAMMING ..................................................................................... 5 STEPPER MOTOR INTERFACING ............................................................................... 7 PIC MICROCONTROLLER ......................... 9 BIT PATTERN ON PORTC ........................................................................................ 10 Timer Operation ........................................................................................................ 12 PWM SIGNAL GENERATION ..................................................................................... 14 ANALOG TO DIGITAL CONVERTER ......................................................................... 16 ARM ...................................................... 18 General Purpose Output Interface ................................................................................ 19 Interfacing with Switch ............................................................................................... 21 ADC Interfacing ........................................................................................................ 23 Timer Interface ......................................................................................................... 24 UART Interfacing ...................................................................................................... 26 LCD Interfacing ........................................................................................................ 28 PSPICE .................................................. 30 CMOS Inverter ......................................................................................................... 31 NAND Gate .............................................................................................................. 32 2:1 Multiplexer .......................................................................................................... 33 4:1 Multiplexer .......................................................................................................... 34 D Latch ................................................................................................................... 36 Full Adder ................................................................................................................ 37 Labview .................................................. 39 Binary to Decimal Conversion ..................................................................................... 40 Odd/Even Number Generation .................................................................................... 42 3 Bit Counter ........................................................................................................... 44 7-Segment Display .................................................................................................... 47 Band Pass IIR Filter ................................................................................................... 50 Rotation of an Array .................................................................................................. 52 MATLAB ................................................ 54 Linear Convolution .................................................................................................... 55 Circular Convolution .................................................................................................. 57 DFT using MATLAB .................................................................................................. 59 2 FFT Using MATLAB ................................................................................................. 61 FIR Low Pass Filter ................................................................................................... 63 FIR High Pass Filter .................................................................................................. 65 Micro Electro Mechanical Systems ............... 67 Cantilever Beam ........................................................................................................ 68 Thermal Bimorph ....................................................................................................... 69 Capacitive Pressure Sensor ......................................................................................... 70 Piezoelectric Shear Actuated Beam .............................................................................. 72 VXWORKS.............................................. 74 Communication through Pipe ....................................................................................... 75 Binary Semaphore ...................................................................................................... 77 Interprocess Communication ....................................................................................... 79 Measuring Of Execution Time ..................................................................................... 82 Pre emptive Scheduling .............................................................................................. 87 Network Simulator 2 ............................... 90 Familiarization of NS2 ................................................................................................ 91 Creation of a Network Topology .................................................................................. 93 Creation of TCP and UDP traffic ................................................................................. 95 Study of Congestion in a network ................................................................................. 98 Flow Control Mechanism in TCP ............................................................................... 100 Creation of Wireless Network .................................................................................... 104 Study of Routing logic in Ad-hoc Network ................................................................... 107 VHDL .................................................. 111 FULL ADDER ........................................................................................................ 112 MULTIPLEXER ...................................................................................................... 113 DECODER ............................................................................................................. 116 MAGNITUDE COMPARATOR .................................................................................. 118 DEMULTIPLEXER .................................................................................................. 119 ALU ...................................................................................................................... 120 3 8051 MICROCONTROLLER (89v51RD2) Pre-requisites : Software required :Operating System : Windows Tools :Keil Supporting Software:Flash magic Hardware required: Development Board :Philips 89V51RD2 kit Interfacing circuits:Nil 4 SWITCH CONTROLLED LED Aim : To write a program to get value from port2 and to send to port0 connected to LED. Procedure : Diagrams : (Circuit/Block/Interfacing Diagrams) Not Applicable Program assembly program: ORG 0000h LJMP MAIN ORG 0100H MAIN: MOV P2, #0FFH ; P2 as input HERE: MOV P0, P2 ; read value from port2 and send to port0 SJMP HERE c program: #include//Define 8051 Registers #define SWP2//Define Switch to Port2 #define LedP0//Define Led to Port0 // Main Function void main() { P2=0xff;//Port-2 as input to FFh P0=0x00;//Port-0 as output to 00h while(1)//Loop Forever { Led = ~SW;/*Assign the Switch value to Led .inverted value isappliedbecause led are connected as common anodetype*/ } } 5 INTERRUPT PROGRAMMING AIM:To write a program to make use of interrupts in 8051 in both assembly and c language. ASSEMBLY PROGRAM: ORG 0000h LJMP MAIN ORG 0003H; external interrupt0 MOV P0,#0FH RETI ORG 000BH; timer1 interrupt CPL P1.1 RETI ORG 0013H; external interrupt1 MOV P0,#0F0H RETI ORG 0100H MAIN: MOV IE,#87H;enable global, timer, external interrupt MOV TMOD,#02H ;timer0 in auto reload mode MOV TH0,#0A4H;for 200us square wave HERE: SJMP HERE C PROGRAM: #include sbit port1 = P1^1; void ext0(void) interrupt 0 { P0=0x0f; } void timer0(void) interrupt 1 { port1 = ~port1; } 6 void ext1(void) interrupt 2 { P0=0xf0; } void main() { P0=0x00; IE=0x87; TMOD=0x02; TH0=0x0A4; TR0=1; while(1); } 7 STEPPER MOTOR INTERFACING AIM:To write a program to rotate a stepper motor in clockwise and anticlockwise direction in 8051 microcontroller. C PROGRAM: #include //Define 8051 registers #include voidDelayMs(unsigned int);//Delay function void main (void) { P0 = 0;//Initialize Port0as output port while(1)//Loop Forever { Clockwise (); DelayMs (500); P0=0; AntiClockwise (); DelayMs (500); P0=0; } } // Clockwise Routine void Clockwise (void) { unsignedint i; for (i=0;i