Pages

Program to convert ASCII to hex in 8051

ASCII codes 30 to 39 represent 0 to 9 in binary and 41 to 46 represent A to F. Therefore

if the ASCII code is between 30-39h then 30h is subtracted from the code. If the number
lies between A to F then 37h is subtracted from the code to get its binary equivalent
mov dptr, #9000h ;load dptr with address 9000h
movx a,@dptr ; move data from external memory location to a
clr c ;clear carry bit
mov r1,a ;move data from a to r1
subb a,#40h ;subtract 40h from a
jc l2 ;jump to location l2, if carry
mov a,r1 ;move data from r1 to a
subb a,#37h ;subtract with borrow, 37h from a
sjmp here ;jump to location here
l2:mov a,r1 ;move data from r1 to a
clr c ;clear carry bit
subb a,#30h ;subtract with borrow, 30h from a
here:inc dptr ;increment dptr
movx @dptr,a ;move data from a to external memory location
rep:sjmp rep
end

Program to add two BCD numbers in 8051

mov dptr,#9000h ;move dptr with 9000h

movx a,@dptr ; move data from external memory location to a
mov b,a ;move data from a to b
inc dptr ;increment dptr
movx a,@dptr ; move data from external memory location to a
add a,b ;add a and b
da a ;decimal adjust accumulator after addition
jc down ;if carry, jump to label down
inc dptr ;increment dptr
movx @dptr,a ;move data from a to external memory location
sjmp last ;jump to label last
down:mov r2,a ;move data from a to r2
mov a,#01h ;move data 01h to a
movx @dptr,a ;move data from a to external memory location
inc dptr ;increment dptr
mov a,r2 ;move data from r2 to a
movx @dptr,a ;move data from external memory location to a
last:sjmp last
end

Program to find the square of an 8 bit number in 8051

mov dptr,#9000h ;load dptr with 9000h

movx a,@dptr ;move data from external memory location to a
mov b,a ;move data from a to b
mul ab ;multiply and b
inc dptr ;increment dptr
mov r0,a ;move data from a to r0
mov a,b ;move data from b to a
movx @dptr,a ;move data from a to external memory location
inc dptr ;increment dptr
mov a,r0 ;move data from r0 to a
movx @dptr,a ;move data from a to external memory location
here:sjmp here
end

Program to count from 0-9 in 8051

here:mov a,#0h ;move 0 to a

up:mov p0,a ;move data from a to port0
acall delay ;call delay routine
add a,#01 ;increment a
cjne a,#010,up ;compare a with 10, if not equal, jump to location up
sjmp here ;jump to location here
;delay routine
delay:mov r1,#0ffh ;move 0ffh to r1
l3:mov r2,#0ffh ;move 0ffh to r2
l2:mov r3,#0ffh ;move 0ffh to r3
l1:djnz r1,l1 ;decrement r1, repeat till r1=0
djnz r3,l2 ;decrement r3,repeat l2 till r3=0
djnz r2,l3 ;decrement r2, repeat l3 till r2=0
ret ;return
end

Program to implement BCD counter to count from 0-99 in 8051

here:mov a,#0h ;move 0 to a

up:mov p0,a ;move data fr
acall delay ;call delay program
inc a ;increment a
da a ;decimal adjust accumulator after addition
cjne a,#100,up ;compare a with 100, if not equal, jump to location up
sjmp here ;jump to location here
delay routine
delay:mov r1,#0ffh ;move 0ffh to r1
l3:mov r2,#0ffh ;move 0ffh to r2
l2:mov r3,#0ffh ;move 0ffh to r3
l1:djnz r1,l1 ;decrement r1, repeat till r1=0
djnz r3,l2 ;decrement r3,repeat l2 till r3=0
djnz r2,l3 ;decrement r2, repeat l3 till r2=0
ret ;return
end

Automatic Room Light Controller

Project title is “AUTOMATIC ROOM LIGHT CONTROLLER WITH BIDIRECTIONAL VISITOR COUNTER “.

The objective of this project is to make a controller based model to count number of persons visiting particular room and accordingly light up the room. Here we can use sensor and can know present number of persons.
In today’s world, there is a continuous need for automatic appliances with the increase in standard of living, there is a sense of urgency for developing circuits that would ease the complexity of life.
Also if at all one wants to know the number of people present in room so as not to have congestion. This circuit proves to be helpful.
Circuit Diagram:1
image


Circuit Diagram: 2


Download Project 

Microcontroller Based Access Control system

Now a days, a problem of security is very much important everywhere   in the world. So, in large firms or companies, to make protect of entering of unauthorized person or to secure their important section, they generally use this type of security.     


vThis project, AN ACCESS CONTROL SYSTEM provides a facility of security. This type of security lock is generally attached at the main entrance door of the firms. By using this type of security, only authorized fellow can enter.

It is quite easy in installation and use. Through this, one can allocate more number of passwords to many fellows. It is easy to use as the fellow don’t need to carry any type of id card or chip etc.
Circuit Diagram:

image




Download Project 

Click on above links to download

CELLPHONE OPERATED LANDROVER

Project Overview

Conventionally, wireless-controlled robots use RF circuits,which have the drawbacks of limited working range, limited frequency range and limited control. Use of a mobile phone for robotic control can overcome these limitations.
It provides the advantages of robust control, working range as large as the coverage area of the service provider,no interference with other controllers and up to twelve controls.Although the appearance and capabilities of robots vary vastly, all robots share the features of a mechanical, movable structure under some form of control.
The control of robot involves three distinct phases: reception, processing and action. Generally, the preceptors are sensors mounted on the robot, processing is done by the on-board microcontroller or processor, and the task (action) is performed using motors or with some other actuators.
Schematic Diagram
image


Block Diagram


Download Project 

Remotely Programmable RTC-Interfaced Microcontroller for Multiple Device Control

Since the circuit makes use of Philips TV remote for device-switching time parameters, you need to know the fundamentals of the coding format used in these IR remotes.



The Philips IR format makes use of RC5 code, which is also known as ‘bi-phase coding.’ In RC5-coded signals (Fig. 2), each bit has a uniform duration. A transition in the middle of the time interval assigned to each bit encodes its logical value (‘0’ or ‘1’). A high-to-low transition assigns the bit a logic value of ‘0,’ and a low-to-high transition assigns the bit a logic value of ‘1.’ We need additional transitions at the beginning of each bit if a stream of equal bits is sent. However, there is no need of additional transitions if the next bit has a different logic value.Table II shows how all the commands of an RC5 remote control are encoded.



The first two bits are ‘start’ bits, which are used to adjust and synchronise the receiver. These bits are used to calculate and analyse the bit length of the other bits. The third bit is a ‘toggle’ bit, which is toggled every time a button ispressed at the remote control. This bit is used to identify whether the button is really pressed or whether an obstacle came in between the IR path of the remote and the IR receiver.
The five bits (A4 through A0) immediately following the toggle bit are used to identify the device (see Table III). So, a maximum of 32 devices can be identified to and respond individually to the same type of coding without any disturbance, i.e., one among the 64 devices can be identified uniquely. Addresses of some of the remotes are shown in Table III. The six bits (C5 through C0) immediately following the five address bits are the control/command bits. Therefore a maximum of 64 commands can be equipped in an RC5-type remote. Some of the command codes (decimal equivalents), as used in this project, are shown in Table IV. When any of the command/control buttons on the remote is pressed, the coded signal is received by the IR receiver-demodulator TSOP1738.The output of the IR demodulator circuit is normally high, but when any of the buttons in the remote is pressed, a stream of low-going demodulated pulses will appear at its output. These pulses are fed to the external active-low interrupt input pin (INT/0) of 89C52. On receipt of the first low-going pulse, the monitor program of 89C52 will get interrupted and jump to the location ‘0003H,’ where the execution is redirected to ‘receive’ sub-routine of the
program.



 The outputs from the subroutineare:
1. Toggle bit, which toggles (either ‘0’ or ‘1’) each time the button in a remote is pressed.
2. Address byte, whose value is zero for a normal Philips-type TV remote control.
3. Control byte, which has a unique value for each button in the remote control. 


Download Project 

Click on above links to download

Program to generate 50msec delay in 8051

mov tmod,#01 ;select timer 0

here:mov tl0,#0fdh ;load tl0 with 0fdh
mov th0,#4bh ;load th0 with 4bh
cpl p1.5 ;compliment p1.5
acall delay ;call delay routine
sjmp here ;jump to here
delay:mov r1,#0c8h ;load r1 with data 0c8h
l1:setb tr0 ;set bit tr0
again:jnb tf0,again ;repeat till tf0=0
clr tr0 ;clear tr0
clr tf0 ;clear tf0
djnz r1,l1 ;decrement r1, jump to l1, if not equal to 0
ret
end

Write a C program to display the code of the key pressed in 8051

#include <REG51xD2.H>

#include "lcd.h"
unsigned char getkey();
void delay(unsigned int);
main()
{
unsigned char key;
InitLcd(); /* Initialise LCD */
WriteString("Key Pressed="); /* Display msg on LCD */
while(1)
{
GotoXY(12,0); /* Set Cursor Position */
key = getkey(); /* Call Getkey method */
}
}
unsigned char getkey()
{
unsigned char i,j,k,indx,t;
P0=0x0ff;
P1=0x0ff;
P2 = 0x00; /* P2 as Output port */
indx = 0x00; /* Index for storing the first value of
scanline */
for(i=0x00E;i>=0x00B;i<<=1) /* for 4 scanlines */
{
P2 = i; /* write data to scanline */
t = P0; /* Read readlines connected to P0*/
t = ~t;
if(t>0) /* If key press is true */
{
delay(6000); /* Delay for bouncing */
for(j=0;j<=7;j++) /* Check for 8 lines */
{
t >>=1;
if(t==0) /* if get pressed key*/
{
k = indx+j; /* Display that by converting to Ascii */
t = k>>4;
t +=0x30;
WriteChar(t); /* Write upper nibble */
t = k & 0x0f;
if(t > 9)
t+=0x37;
else
t+=0x30;
WriteChar(t); /* write lower nibble */
return(indx+j); /* Return index of the key pressed */
}
}
}
indx += 8; /* If no key pressed increment index */
}
}
void delay(unsigned int x) /* Delay routine */
{
for(;x>0;x--);
}

program for Elevator Interface in 8051

#include <REG51F.H>

void delay(unsigned int);
main()
{
unsigned char Flr[9] = {0xff,0x00,0x03,0xff,0x06,0xff,0xff,0xff,0x09};
unsigned char FClr[9] = {0xff,0x0E0,0x0D3,0xff,0x0B6,0xff,0xff,0xff,0x79};
unsigned char ReqFlr,CurFlr = 0x01,i,j;
P0 = 0x00;
P0 = 0x0f0;
while(1)
{
P1 = 0x0f;
ReqFlr = P1 | 0x0f0;
while(ReqFlr == 0x0ff)
ReqFlr = P1 | 0x0f0; /* Read Request Floor from P1 */
ReqFlr = ~ReqFlr;
if(CurFlr == ReqFlr) /* If Request floor is equal to Current Floor */
{
P0 = FClr[CurFlr]; /* Clear Floor Indicator */
continue; /* Go up to read again */
}
else if(CurFlr > ReqFlr) /* If Current floor is > request floor */
{
i = Flr[CurFlr] - Flr[ReqFlr]; /* Get the no of floors to travel */
j = Flr[CurFlr];
for(;i>0;i--) /* Move the indicator down */
{
P0 = 0x0f0|j;
j--;
delay(25000);
}
}
else /* If Current floor is < request floor */
{
i = Flr[ReqFlr] - Flr[CurFlr]; /* Get the no of floors to travel */
j = Flr[CurFlr];
for(;i>0;i--) /* Move the indicator Up */
{
P0 = 0x0f0 | j;
j++;
delay(25000);
}
}
CurFlr = ReqFlr; /* Update Current floor */
P0 = FClr[CurFlr]; /* Clear the indicator */
}
}
void delay(unsigned int x)
{
for(;x>0;x--);
}

program for Stepper motor interface in 8051


#include <REG51xD2.H>
static bit Dir=0;
void delay(unsigned int x) /* Delay Routine */
{
for(;x>0;x--);
}
void ChangeDir(void) interrupt 0 /* Int Vector at 000BH, Reg Bank 1 */
{
Dir = ~Dir; /* Complement the Direction flag */
ClrLcd();
if(Dir)
delay(32000);
else
delay(32000);
}
main()
{
unsigned char Val,i;
EA=0x1; /* Enable Interrupt flag and Interrupt 0 & Serial Interrupt */
EX0=0x1;
ES=0x1;
P0=0x00; /*since the monitor is using the serial interrupt it has to be enabled*/
while(1)
{
if(Dir) /* If Dir Clockwise */
{
Val = 0x88;
for(i=0;i<4;i++)
{
P0 = Val; /* Write data for clock wise direction*/
Val = Val>>1;
delay(575);
}
}
else /* AntiClockwise Direction */
{
Val = 0x11;
for(i=0;i<4;i++)
{
P0 = Val; /* Write data for anticlock wise direction*/
Val = Val<<1;
delay(575);
}
}
}
}