You are on page 1of 36

Lab No # 11

TO STUDY THE TOOLS AND SOFTWARE


USE FOR MICROCONTROLLER I.E.
PROTEUS, MIKROC, KEIL ETC

INTRODUCTION TO PROTEUS:-
ISIS & ARES CORE APPLICATIONS:

Improved 'follow me' wire routing in isis.

Layout technology files / technology menu


- these are effectively templates for pcb layout.
- board edge, drill holes and other mechanical data may be
pre-placed.
- design rules, and net-classes may be pre-defined.
- grids, start up units, layer usage, and font sizes may be pre-
defined.
- technology data can been used for new designs and/or
applied to existing ones.

Colour sets in ares


- switch between different visible layers and colours from the
view-layers dialogue.
- use a different colour set for printing as opposed to editing.
- work with a non-black background colour.

Dimensions of pad styles are shown in the preview window.

Rewritten/improved online help system based on html help.

Fully compatible with windows 7.

PROTEUS VSM
Cpu models for pic24f04ka200, pic24f04ka201, pic24f08ka101,
pic24f08ka102, pic24f16ka101, pic24f16ka102

Vsm studio* - an ide for proteus vsm that greatly simplifies the
process building your source code and attaching the object
code to a schematic. More information about vsm studio may
be found here.

Lots of new sample designs for 8051, arm and avr.

INTRODUCTION TO MIKROC PRO FOR


8051:-

The mikroc PRO for 8051 is a powerful, feature-rich development tool 8051
microcontrollers. It is designed to provide the programmer with the
easiest possible solution to developing applications for embedded
systems, without compromising performance or control.

FEATURES
Mikroc PRO for 8051 allows you to quickly develop and deploy
complex applications:

Write your C source code using the built-in Code Editor (Code and
Parameter Assistants, Code Folding, Syntax Highlighting, Auto
Correct, Code Templates, and more.)

Use included mikroc PRO for 8051 libraries to dramatically speed up


the development: data acquisition, memory, displays, conversions,
communication etc.

Monitor your program structure, variables, and functions in the Code


Explorer.

Generate commented, human-readable assembly, and standard HEX


compatible with all programmers.
Inspect program flow and debug executable logic with the integrated
Software Simulator.

Get detailed reports and graphs: RAM and ROM map, code statistics,
assembly listing, calling tree, and more.

Mikroc PRO for 8051 provides plenty of examples to expand,


develop, and use as building bricks in your projects. Copy them
entirely if you deem fit thats why we included them with the
compiler.

INTRODUCTION TO KEIL UVISION3:-

Keil development tools for the 8051 microcontroller family support


every level of developer from the professional applications engineer
to the student just learning about embedded software development.
The industry-standard Keil C Compilers, Macro Assemblers,
Debuggers, Real-time Kernels, and Single-board Computers support
ALL 8051-compatible derivatives and help you get your projects
completed on schedule.

The following table shows the Keil C51 Product Line (across the top)
and the Components that are included (along the left side). You may
use this information to find the development tool kit that best fits
your needs.

Lab No # 12
USE THE PORTS AS OUTPUT BY INVERTING ITS
BITS AFTER CERTAIN DELAY TIME

AIM:-
There are some main tasks in this lab that I have to
perform.
To write a program in Keil using assembly language to
toggle the bits at Port 1 after a certain delay.
To implement any of the above program on AT89C51 -
processor in Proteus Software.

ALGORITHM:-
Start the program from 00H.
Move 55H to port 1.
Delay will be call.
Move 55H to port 1.
Delay will be call.
Short jump in main
Delay Subroutine will be
Move 255 value to R1.
Move 255 value to R2.
Move 7 value to R2.
Decrement R3 and jump to again3.
Decrement R2 and jump to again2.
Decrement R1 and jump to again1.
Return the subroutine.
End the program.

PROGRAM:-
Program on Keil Using Assembly Language:
ORG 00H

MAIN: MOV P1, #55H

ACALL DELAY ; Calling delay subroutine

MOV P1, #0AAH ; Toggle Bits of P1

SJMP MAIN ; For Infinite Run

DELAY: MOV R1, #255 ; Runs 1 time, Delay: 1.2u Sec

AGAIN1: MOV R2, #225 ; Runs 255 times, Delay 306u Sec

AGAIN2: MOV R3, #7 ; Runs 255*225 times, Delay 68.85m Sec


AGAIN3: DJNZ R3, AGAIN3 ; Runs 255*225*7 times, Delay 0.96 Sec

DJNZ R2, AGAIN2 ; Runs 255*250 times, Delay 0.135 Sec

DJNZ R1, AGAIN1 ; Runs 255 times, Delay 612u Sec

RET ; Runs 1 time, Delay 2.4u Sec

; Total time Delay=1.001 Sec

END

OBSERVATION:-

P1 === 55H
P1 == AAH

RESUTL:-
Use the ports as output by inverting its bits.
SOFTWARE PICTURE:-

Program in Keil
Proteus 7 Professional

Lab No # 13
TO USE PORTS AS INPUT AND OUTPUT IN
PIC MICROCONTROLLERS
AIM:-
To use the PORT B as input and PORT D as an output of a
PIC microcontroller (P18F452).

ALGORITHM:-
Start the program from main ().
TRISB to OXFF;
TRISB to OX00;
While loop is infinity time.
Port B to Port D.

PROGRAM:-
Program on microC PRO Language:

void main()
{
TRISB=0xFF; // declaring PORT B as input

TRISD=0x00; // declaring PORT D as output

While (1)

{
PORTD=PORTB ;
} // Move the input to output
}

OBSERVATION:-
First we have to declare Port B as the
input port and PORT D as the output port. Now connect the crystal
to microcontroller and a reset switch which is active High switch.
Connect the LEDs at the output to check your result.

RESUTL:-
To use ports as input and output in two pic
microcontrollers

SOFTWARE PICTURE:-

Program in Keil
Proteus 7 Professional
Lab No # 15
TO USE PORTS AS INPUT AND OUTPUT &
INTERCONNECT TWO PIC
MICROCONTROLLERS

AIM:-
Use two PIC u-controllers. Give input at first and take
output from second.

ALGORITHM:-
Start the program from main ().
TRISB to OXFF;
TRISB to OX00;
While loop is infinity time.
Port B to Port D.

PROGRAM:-
Program on microC PRO Language:

void main()
{
TRISB=0xFF; // declaring PORT B as input

TRISD=0x00; // declaring PORT D as output

While (1)

{
PORTD=PORTB ;
} // Move the input to output
}
OBSERVATION:-
First of all we have to declare
Port B of 1st u-controller as input and Port D as the output
in the 1st program. Then declare the Port B of 2nd u-
controller as the input and the Port C as output in the 2 nd
program.

RESUTL:-
To use ports as input and output in pic
microcontrollers

SOFTWARE PICTURE:-

Program in Keil
Proteus 7 Professional
Lab No # 16
TO MADE THE TWO TRAFFIC SIGNAL
LIGHTS SUCH THAT ONLY ONE WAY IS ON

AIM:-
We have to make the circuit such that One Way traffic is
on at a time.

ALGORITHM:-
Define Red1 and Red2 on P1.0 and P2.0.
Define Y1 and Y2 on P1.1 and P2.1.
Define G1 and G2 on P1.2 and P2.2.
Start main and the while loop for infinitely.
Initially all the lights are off except the Red1 and Green 2
Delay for 10 sec so that the lights are on
Green of 1st is off
Yellow of 1st is on
Yellow of 2nd is on
Delay for 2 sec Red of 1st is off
Yellow of 1st is off
Yellow of 2nd is off
Green of 1st is on
Red of 2nd is on
Delay for 10 sec
Green of 1st is off
Yellow of 1st is on
Yellow of 2nd is on
Delay for 2 sec
End the program
PROGRAM:-
Program on C Language:

#define Red1 P1.b0 // defining bit 0 of port 1

#define Red2 P2.b0 // defining bit 0 of port 2

#define Y1 P1.b1 // defining bit 1 of port 1

#define Y2 P2.b1 // defining bit 1 of port 2

#define G1 P1.b2 // defining bit 2 of port 1

#define G2 P2.b2 // defining bit 2 of port 2

void main() {

while (1) // for infinite loop run

Red2=1; // initially all the lights are off except the Red1 and Green 2

G1=1; // Green of 1st is off

Y1=1; // Yellow of 1st is off

Y2=1; // Yellow of 2nd is off

Red1=0; // Red of 1st is on

G2=0; // Green of 2nd is on

Delay_ms(10000); // delay for 10 sec so that the lights are on

G2=1; // Green of 1st is off

Y1=0; // Yellow of 1st is on

Y2=0; // Yellow of 2nd is on

Delay_ms(2000); // Delay for 2 sec

Red1=1; // Red of 1st is off

Y1=1; // Yellow of 1st is off


Y2=1; // Yellow of 2nd is off

G1=0; // Green of 1st is on

Red2=0; // Red of 2nd is on

Delay_ms(10000); // Delay for 10 sec

G1=1; // Green of 1st is off

Y1=0; // Yellow of 1st is on

Y2=0; // Yellow of 2nd is on

delay_ms(2000); // Delay for 2 sec

RESUTL:-
We have to make the programming such that on
way is on at a time. The below programming shows that initially Red
light of 1st Signal is on and at same time Green of 2nd is on for 10 sec
. Now then Yellow and Red of 1st is on (to show that ready to go) and
at same time only yellow of 2nd is on (to show that ready to stop) for
2 sec. Now the Red of 2nd and green of 1st is on at the same time for
10 sec. Then the only the yellow of 1st (to show that ready to stop)
and the Red & Yellow of 2nd is on (to show that ready to go) for 2 sec
and then Red of 1st with green of 2nd and so on.

SOFTWARE PICTURE:-
Program in microC PRO
Proteus 7 Professional
Lab No # 17
TO USE THE INTERRUPTS IN MICKROC

AIM:-
Write a C program that continuously gets a single bat of
data from P1.7 and send it to P2.0 in the main while simultaneously
creating a square wave of 200us period on P2.5 and sending a
Latter A to the serial port. Use timer 0 to create the square wave.
Assume that XTAL=11.0592MHz. Use 9600 baud rate.

PROGRAM:-
Program on C Language:

sbit input at P1.b7;

sbit output at P2.b0;

sbit sent at P2.b5;

sbit trans at TI_bit;

sbit recv at RI_bit;

sbit strt0 at TR0_bit;

sbit strt1 at TR1_bit;

void timer0(void) interrupt 1

{sent=~sent; //toggle pin

}
void serial0(void) org 0x0023

{if (trans==1)

{SBUF='A'; // send A to serial port

trans=0;

else

{recv=0;}

void main() {

input=1;

TMOD=0x22;

TH1=253;

TH0=0xA4;

strt0=1;

strt1=1;

SCON=0x50;

IE=0x92;

while(1){

output=input;

}
SOFTWARE PICTURE:-

Program in Keil uVision3

Proteus 7 Professional
Lab No # 18
TO INTERFACE MICROCONTROLLER WITH
LCD USING MIKROC

AIM:-
How to interface the LCD with 8051 and PIC Microcontroller.

PROGRAM:-
sbit LCD_RS at P2_0_bit; // defining RS

sbit LCD_EN at P2_1_bit;

sbit LCD_D7 at P2_7_bit; // defining D7 of LCD

sbit LCD_D6 at P2_6_bit; // defining D6 of LCD

sbit LCD_D5 at P2_5_bit; // defining D5 of LCD

sbit LCD_D4 at P2_4_bit; // defining D4 of LCD

void main() {

unsigned char n1[]="ZULQADAR HASSAN"; // my name store in n1


character

unsigned char n2[]="CLASS NO 08"; // class no stored in n2


character

Lcd_init(); // initialize LCD

LCD_RS=0; // set LCD for command

Lcd_Cmd(_LCD_CLEAR); // Clear LCD Screen

LCD_RS=1; // set LCD for Output

Lcd_Out(1,1,n1); // Display output at row 1, column 1

Lcd_Out(2,1,n2);// Display output at row 2, column 1


LCD_RS=0; // set LCD for command

Lcd_Cmd(_LCD_CURSOR_OFF); // off the curser blinking.

RESUTL:-
First we will make the programming for 8051 such that firstly clear the LCD
(using command, for command RS=0) and then display the output (RS=1) and then stop
the curser which is blinking (RS=0).

SOFTWARE PICTURE:-

Program in microC PRO


Proteus 7 Professional
Lab No # 19
TO PERFORM ADDITION OF TWO 8 BIT
NUMBER USING 8051 INSTRUCTION SET
AIM:-
To perform addition of two 8-bit numbers using 8051
instruction set

ALGORITHM:-
Start from 00H.
Clear the carry.
Move 25H to accumulator.
Move 45H to R1.
Adding them.
Move 2300H to data pointer.
Move accumulator value to data pointer memory address.
End the program.

PROGRAM:-
Program on Keil Using Assembly Language:
ORG 00H

CLR C

MOV A # 25H

MOV R1 # 45H

ADD A, R1

MOV DPTR, #2300H

MOVX @DPTR, A
END

OBSERVATION:-

Input
A == 25H
R1 = 45H
Output
A = 6AH

RESUTL:-
Addition of two 8-bit numbers.
SOFTWARE PICTURE:-

Program in Keil
Lab No # 20
TO PERFORM SUBTRACTION OF TWO 8
BIT NUMBER USING 8051 INSTRUCTION
SET
AIM:-
To perform subtraction of two 8-bit numbers using 8051
instruction set

ALGORITHM:-
Start from 00H.
Clear the carry.
Move 75H to accumulator.
Move 45H to R1.
Subtracting them.
Move 2300H to data pointer.
Move accumulator value to data pointer memory address.
End the program.

PROGRAM:-
Program on Keil Using Assembly Language:

ORG 00H

CLR C

MOV A # 75H

MOV R1 # 45H

SUBB A, R1
MOV DPTR, #2300H

MOVX @DPTR, A

END

OBSERVATION:-

Input
A == 75H
R1 = 45H
Output
A = 30H

RESUTL:-
Subtraction of two 8-bit numbers.
SOFTWARE PICTURE:-

Program in Keil
LAB NO # 21
TO PERFORM MULTIPLICATION OF TWO 8
BIT NUMBER USING 8051 INSTRUCTION
SET
AIM:-
To perform multiplication of two 8-bit numbers using
8051 instruction set

ALGORITHM:-
Start from 00H.
Clear the carry.
Move 75H to accumulator.
Move 45H to R1.
Multiplying them.
Move 2300H to data pointer.
Move accumulator value to data pointer memory address.
End the program.

PROGRAM:-
Program on Keil Using Assembly Language:

ORG 00H

CLR C

MOV A # 75H

MOV B # 45H

MUL AB
MOV DPTR, #2300H

MOVX @DPTR, A

MOV A, B

MOVX @DPTR, A

END

OBVESATION:-

Input
A == 75H
B = 45H
Output
A = BA H
B = 00 H

RESUTL:-
Multiplication of two 8-bit numbers.
SOFTWARE PICTURE:-

Program in Keil
LAB NO # 22
TO PERFORM DIVISION OF TWO 8 BIT
NUMBER USING 8051 INSTRUCTION SET
AIM:-
To perform division of two 8-bit numbers using 8051
instruction set

ALGORITHM:-
Start from 00H.
Clear the carry.
Move 80H to accumulator.
Move 02H to B.
Diving them.
Move 2300H to data pointer.
Move accumulator value to data pointer memory address.
End the program.

PROGRAM:-
Program on Keil Using Assembly Language:
ORG 00H

CLR C

MOV A # 80H

MOV B # 02H

DIV AB
MOV DPTR, #2300H

MOVX @DPTR, A

MOV A, B

MOVX @DPTR, A

END

OBVESATION:-

Input
A == 80H
B = 02H
Output
A = 40 H
B = 00 H

RESUTL:-
Division of two 8-bit numbers.
SOFTWARE PICTURE:-

Program in Keil

You might also like