You are on page 1of 36

Ex. No : 1 Date : Aim 1. 2.

BASIC ELECTRONICS

To check the following components using multimeter: Resistor, Capacitor, Diode, Transistor, LED, LDR, Relay To construct a 5V regulated DC Power supply using IC 7805.

Apparatus and components required S.No 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. Apparatus / Component Digital Multimeter Resistor Capacitor Diode Transistor LED LDR Relay AC adapter Bridge rectifier Capacitor IC Breadboard Connecting wires Type / Range Any value Any value 1N4001, BY127 BC547, SK100 5 mm 6V / 12V 230V 9V AC 1000uF, 10uF, 100 nF 7805 Quantity 1 No. 2 Nos. 2 Nos. Each 1 No. Each 1 No. 1 No. 1 No. 1 No. 1 No. 1 No. Each 1 No. 1 No. 1 No. 1 Set

Circuit diagram for Regulated DC Power supply

Observation S.No 1. 2. 3. 4. 5. 6. Component Resistor 1 Resistor 2 Capacitor 1 Capacitor 2 Diode 1 Diode 2 Symbol

Components Base diagram Observation / Test result

7.

Transistor 1

8.

Transistor 2

9.

LED

10.

LDR

11.

Relay

DC Power supply Pin diagram of IC 7805

Voltage at the output of AC adapter Voltage across the filter capacitor Voltage at the output of regulator IC Result 1. 2. The given components are tested using multimeter. A 5V DC regulated power supply has been constructed and tested. ----------

Ex. No : 1.B Date : Aim 1. 2.

DIGITAL ELECTRONICS

To verify the truth table of the following gates: AND, OR, NOT, NAND, NOR, EX OR To construct a half adder circuit using gates.

Apparatus and components required S.No 1. 2. 3. 4. 5. 6. 7. 8. 9. Apparatus / Component Digital Multimeter AND gate OR gate NOT gate NAND gate NOR gate EX OR gate Digital IC trainer Connecting wires IC 7408 IC 7432 IC 7404 IC 7400 IC 7402 IC 7486 Type / Range Quantity 1 No. 1 No. 1 No. 1 No. 1 No. 1 No. 1 No. 1 No. 1 Set

Circuit diagram for half adder

Observation Verification of gates


S.No IC Symbol Pin diagram A Truth table B Y

1.

AND gate IC 7408

2.

OR gate IC 7432

3.

NOT gate

S.No

IC

Symbol

Pin diagram

Truth table B Y

IC 7404

4.

NAND gate IC 7400

5.

NOR gate IC 7402

6.

EX OR gate IC 7486

Half adder Input Output A B Carry Sum

Result 1. The truth tables of all the gates have been verified. 2. A half adder circuit has been constructed and tested.

Ex. 2 - Assembly Language Programming


Aim : To write 8051 assembly language program for 8-bit addition, subtraction, multiplication and division and verify. Program : 8-bit addition Address Op. codes Label Mnemonics Comments

MOV DPTR, #9000 MOVX A, @DPTR MOV R0, A INC DPTR MOVX A, @DPTR MOV B, A MOV A, R0 MOV R1, #00 CLR C ADD A, B JNC NOCARRY INC R1 NOCARRY : MOV DPTR, #9500 MOVX @DPTR, A INC DPTR MOV A, R1 MOVX @DPTR, A HERE : Address 9000 9001 Output Address 9500 9501 Data Sum Carry SJMP HERE Input Data First number Second number

Program : Address 8100 Op. codes Label

8-bit subtraction
Mnemonics MOV DPTR, #9000 MOVX A, @DPTR Comments

MOV R0, A INC DPTR MOVX A, @DPTR MOV B, A MOV A, R0 MOV R1, #00 CLR C SUBB A, B JNC NOBORROW INC R1 NOBORROW : MOV DPTR, #9500 MOVX @DPTR, A INC DPTR MOV A, R1 MOVX @DPTR, A HERE : Address 9000 9001 Output Address 9500 9501 Data Difference Borrow SJMP HERE Input Data First number Second number

Program :

8-bit multiplication
Address 8100 Op. codes Label Mnemonics MOV DPTR, #9000 Comments

MOVX A, @DPTR MOV R0, A INC DPTR MOVX A, @DPTR MOV B, A MOV A, R0 MUL AB MOV DPTR, #9500 MOVX @DPTR, A INC DPTR MOV A, B MOVX @DPTR, A HERE : SJMP HERE Input Address 9000 9001 Output Address 9500 9501 Data Product (Lower order byte) Product (Higher order byte) Data First number Second number

Program :

8-bit division
Address 8100 Op. codes Label Mnemonics MOV DPTR, #9000 Comments

MOVX A, @DPTR MOV R0, A INC DPTR MOVX A, @DPTR MOV B, A MOV A, R0 DIV AB MOV DPTR, #9500 MOVX @DPTR, A INC DPTR MOV A, B MOVX @DPTR, A HERE : SJMP HERE Input Address 9000 9001 Output Address 9500 9501 Result: The assembly language program for 8-bit addition, subtraction, and division Written and verify multiplication Data Quotient Remainder Data First number Second number

KEIL COMPILER AND PROGRAM DOWNLOADER . KEIL COMPILER

1.

To create a new project: Project New Project Select / Create your folder. Type the new project name. Click on Save. Double click on Atmel. Click on AT89C51. Click on OK. Right click on Target 1. Select Options for Target Target 1. Select the Output tab. Tick on Create Hex File. Click on OK.

2.

To type the program: File New. Type the program.

3.

To save the program: File Save. Give the file name with .C extension. Click on Save.

4.

To add the program file to the project: Double click on Target 1. Right click on Source Group 1. Click on Add file to Group Source Group 1. Select the file. Click on Add. Click on Close.

5.

To create the HEX file: Project Build Target. HEX file will be create with the name of the Project file.

6.

To Debug / Simulate the program: Debug Start/Stop Debug Session Peripherals I/O-Ports. Select the I/O port. Press F11 to step the program. Verify the execution of the program.

PROGRAM DOWNLOADER 1. Select the device. 2. Load the HEX file. 3. Erase the chip. 3. Program the chip.

8-BIT LED binary counter Ex.No.:3 Date: AIM: To write 8051 C language program for 8-BIT LED binary counter and test. APPARATUS REQUIRED: S.No Apparatus / component 1 Capacitor 2 3 4 Resistor Crystal Microcontroller Type / Range 10uf / 16V, 33pf 10Kx 8 array,10k, 220x8 ohms array 12mHz AT89C51 Quantity 1No. 2Nos. 1No. 1No. 1No.

LED Blinking : One LED is connected at Port P1.0 #include <At89x51.h> sbit mybit = P1^0; void main(void) { int i; mybit = 0; while(1) { mybit = !mybit; for(i=1;i<=20000;i+ +); } } #include "At89x51.h" sbit mybit = P1^0; void main(void) { void delay50ms(int); while(1) { mybit = !mybit; delay50ms(20); } } void delay50ms(int x) { int i; for(i=1;i<=x;i++) { TMOD = 1;

TH0 = 0x3C; TL0 = 0xB0; TF0 = 0; TR0 = 1; while(TF0 != 1); TF0 = 0; TR0 = 0; } } Binary Counter : Eight LEDs are connected at Port P1 #include <At89x51.h> void main(void) { int i,k; while(1) { for(i=0;i<=255;i++) { P1 = i; for(k=1;k<=20000;k++); } } } Running Lights : Eight LEDs are connected at Port P1 #include <At89x51.h> void main(void) { int i,k; while(1) { for(i=1;i<=255;i=i*2) { P1 = i; for(k=1;k<=2000 0;k++); } } } RESULT: The C language for 8-BIT LED binary counter was written and verified.

Seven segment display Ex.No.:4 Date: AIM: To write 8051 C language program for seven segment display and test. APPARATUS REQUIRED: S.No Apparatus / component Type / Range Quantity 1 Capacitor 10uf / 16V, 1No. 33pf 2Nos. 2 Resistor 10Kx 8 array,10k, 1No. 3 4 Crystal Microcontroller 12mHz AT89C51 1No. 1No.

Display number 5 : One 7-segment display is connected at Port P1. Display select is connected at P2.0 #include <At89x51.h> void main() { while(1) { P1 = 0x6d; P2_0 = 1; } } Seconds counter : One 7-segment display is connected at Port P1, Display select is connected at P2.0 #include <At89x51.h> void delay50ms(int); int dat[10]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7c,0x07,0x7 f,0x6f}; void main() { int i=0; while(1) { P1 = dat[i]; P2_0 = 1; delay50ms(20); i++; if(i>9) i = 0; } }

void delay50ms(int x) { int i; for(i=1;i<=x;i++) { TMOD = 1; TH0 = 0x3C; TL0 = 0xB0; TF0 = 0; TR0 = 1; while(TF0 != 1); TF0 = 0; TR0 = 0; } } RESULT: The C language for seven segment display was written and verified.

UP / DOWN COUNTER Ex.No.:5 Date: AIM: To write 8051 C language program for one digit up/down counter and verify. APPARATUS REQUIRED: S.No 1 2 3 4 Apparatus / component Capacitor Resistor Crystal Microcontroller Type / Range 10uf / 16V, 33pf 10K,10k x 8 array 10mHz AT89C51 Quantity 1No. 2Nos. 1No. 1No. 1No.

UP / DOWN COUNTER: One 7-segment display is connector at port P1, Display select is connector at P2.0. Up switch is connected at P2.4 and Down switch is connector at P2.5. PROGRAM: #include <At89x51.h> int dat[10]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x 07,0x7,0x6f}; void main() { int i=0,j; P2_4 = 0; P2_5 = 0; while(1) { P1 = dat[i]; P2_0 = 1; if(P2_4 == 1) { for(j=1;j<=1500;j++); if(P2_4 == 1) { i++; if(i>9) i = 0; while(P2_4 == 1); } }

if(P2_5 == 1) { for(j=1;j<=1500;j++); if(P2_5 == 1) { i--; if(i<0) i = 9; while(P2_5 == 1); } } } } RESULT: The C language for one digit up / down counter was written and verified.

Matrix keyboard Ex.No.:6 Date: AIM: To write 8051 C language program to display the key pressed on the 7 segment display and verify. APPARATUS REQUIRED: S.No 1 Apparatus / component 8051 ISP Development Board Trainer Kit Type / Range Quantity 1No.

PROGRAM: #include <At89x51.h> int keyboard(void); sbit R1 = P3^0; sbit R2 = P3^1; sbit R3 = P3^2; sbit R4 = P3^3; sbit C1 = P3^4; sbit C2 = P3^5; sbit C3 = P3^6; sbit C4 = P3^7; int dat[10]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7c,0x07,0x 7f,0x6f}; void main() { int i=0; while(1) { i = keyboard(); if(i<=9) P1 = dat[i]; else P1 = 0; P2_0 = 1; } }

int keyboard(void) {

int k; C1 = 1; C2 = 1; C3 = 1; C4 = 1; R1 = 0; R2 = 1; R3 = 1; R4 = 1; if(C1 == 0) k=0; if(C2 == 0) k=1; if(C3 == 0) k=2; if(C4 == 0) k=3; R1 = 1; R2 = 0; R3 = 1; R4 = 1; if(C1 == 0) k=4; if(C2 == 0) k=5; if(C3 == 0) k=6; if(C4 == 0) k=7; R1 = 1; R2 = 1; R3 = 0; R4 = 1; if(C1 == 0) k=8; if(C2 == 0) k=9; if(C3 == 0) k=10; if(C4 == 0) k=11; R1 = 1; R2 = 1; R3 = 1; R4 = 0; if(C1 == 0) k=12; if(C2 == 0) k=13; if(C3 == 0) k=14; if(C4 == 0) k=15; return(k); } RESULT: The C language for key pressed on the 7 segment display was written and verified by matrix keyboard.

MULTIPLEXED DISPLAY Ex.No.:7 Date: AIM: To display the number 2009 using multiplexed display. APPARATUS REQUIRED: S.No 1 Apparatus / component 8051 ISP Development Board Trainer Kit Type / Range Quantity 1No.

PROGRAM: //program for MULTIPLEXED DISPLAY #include <At89x51.h> int dat[10]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0 x7f,0x6f}; void main() { int i; while(1) { P1=0X6F; P2=1; for(i=1;i<=100;i++); P1=0X3F; P2=2; for(i=1;i<=100;i++); P1=0X3F; P2=4; for(i=1;i<=100;i++); P1=0X5b; P2=8; for(i=1;i<=100;i++); } } RESULT: The number 2009 is displayed in a 7-segment display using multiplexed display.

LCD DISPLAY Ex.No.:8 Date: AIM: To display the given sentence in two lines using LCD display. APPARATUS REQUIRED: S.No 1 Apparatus / component 8051 ISP Development Board Trainer Kit Type / Range Quantity 1No.

PROGRAM: Data bus is connected to P1. RS is connected to P2_0. RW is connected to P2_1. EN is connected to P2_2. #include "at89x51.H" #define RS P2_0 #define RW P2_1 #define EN P2_2 void delay(void); void INIT(void); void ENABLE(void); void LINE1(char *s); void LINE2(char *s); void LINE1(char *s) { int j; char *p; RS=0; RW=0; P1=0x80; ENABLE(); RS=1; p=s; for (j=0;j<=15;j++) { P1= *p++; ENABLE(); } } void LINE2(char *s) { int j; char *p; RS=0; RW=0; P1=0xC0; ENABLE();

RS=1; p=s; for (j=0;j<=15;j++) { P1= *p++; ENABLE(); } } void delay() { int i; int j; for (j=0;j<10;j++) { for (i=0;i<100;i++); } } void ENABLE(void) { EN=1; delay(); EN=0; delay(); } void INIT(void) { RS=0; RW=0; EN=0; P1 = 0x38; ENABLE(); ENABLE(); ENABLE(); ENABLE(); P1 = 0x06; ENABLE(); P1 = 0x0E; ENABLE(); P1 = 0x01; ENABLE(); }

void main (void)

{ char code dis[] = "GOD IS LOVE "; char code dis2[] = "HAVE A NICE DAY ; INIT(); LINE1(dis); LINE2(dis2); while(1) { } } RESULT: The given sentence is displayed in LCD display.

DC MOTOR Ex.No.:9.A Date: AIM: To write a program to monitor the status of p2-0 and the performance the following. If p2-0=0, the DC Motor does not rotate. If p2-0=1, the DC Motor rotate with 25% duty cycle pulse. APPARATUS REQUIRED: S.No Apparatus / component Type / Range Quantity 1 8051 Development Board 1No. PROGRAM: DC Motor is connected at P1_0. Switch is connected at P2_0. #include<At89x51.h> void main() { int i; P2_0=1; P1_0=0; while(1) { P2_0 = 0; if (P2_0==1) { P1_0=1; for(i=1;i<=2000;i++); P1_0=0; for(i=1;i<=1000;i++); } if (P2_0==0) { P1_0=1; for(i=1;i<=1000;i++); P1_0=0; for(i=1;i<=2000;i++); } } } RESULT: A C program for DC motor interface was written ad verified.

RELAY Ex.No.:10.A Date: AIM: To write C language program for interfacing relay with 8051. APPARATUS REQUIRED: S.No 1 Apparatus / component 8051 Development Board Type / Range Quantity 1No.

PROGRAM: Relay is connted at P1_0. #include<At89x51.h> void main(void) { int i; while(1) { P1_0=1; for(i=1;i<=5000;i++); P1_0=0; for(i=1;i<=30000;i++); } } RESULT: The C program for interfacing relay with 8051 was written and verified.

BUZZER Ex.No.:10.B Date: AIM: To write C language program for interfacing buzzer with 8051. APPARATUS REQUIRED: S.No 1 Apparatus / component 8051 Development Board Type / Range Quantity 1No.

PROGRAM: Buzzer is connected at P1_0. #include<At89x51.h> void main(void) { int i; while(1) { P1_0=1; for(i=1;i<=5000;i++); P1_0=0; for(i=1;i<=80000;i++); } } RESULT: The C program for interfacing buzzer with 8051 was written and verified.

STEPPER MOTOR Ex.No.:11. Date: AIM: To write C language program to control the stepper motor. APPARATUS REQUIRED: S.No Apparatus / component Type / Range 1 8051 Development Board PROGRAM: #include<At89x51.h> void MSDelay (int value); void main() { P2_0 = 1; while(1) { if(P2_0 == 1) { P1=0x09; MSDelay(1); P1=0x0c; MSDelay(1); P1=0x06; MSDelay(1); P1=0x03; MSDelay(1); } else { P1=0x03; MSDelay(1); P1=0x06; MSDelay(1); P1=0x0c; MSDelay(1); P1=0x09; MSDelay(1); } } } void MSDelay(int value) { int X,Y; for(X=0;X<1275;X++) for(Y=0;Y<value;Y++); } RESULT: The C program to control the stepper motor was written and verified.

Quantity 1No.

You might also like