Search This Blog

Showing posts with label VDD. Show all posts
Showing posts with label VDD. Show all posts

Tuesday, 9 June 2015

How to make password based door lock system project using assembly language 8051

Hello everyone!!!!
I have recently been working on 8051 micro controller. the 8051 micro controller is a very versatile controller to be programmed and implemented at various levels.
In this blog we will discuss about the 8051 micro controller password based door lock system using assembly language.

LET US START MAKING THE PROJECT "PASSWORD BASED DOOR LOCK SYSTEM" 

STEP 1: SIMULATE PROJECT ON A SOFTWARE: 

Showing below is the circuit diagram of "Password based door lock system" simulated on proteus 7


PARTS USED:

1) AT89C51 (micro controller)
2) 4*4 hexpad (for input)
3) MM74C922 (key decoder)
4) L293D ('H' drive IC)
5) Motor
6) Not gate
7) lM016l (LCD)

Simulation is not a very hard thing to do!!! just connect the wires as shown in the diagram the wires with 'blue' 'brown' and 'red' color represents the 'buses'. the bus connects the wires that are labeled same on different ports. 

STEP 2: PROGRAMMING!!

The most important step is the programming... For this you will need some knowledge of 8051 micro controller.

  • Let us start with the programming of  LCD:

In order to interface LCD please click on the link below:

  • How to interface keypad?


In order to interface keypad please click on the link below:


IF ANYONE IS INTERESTED IN FULL CODING OF THIS PROJECT CAN CONTECT US ON THIS BLOG OR ON OUR EMAIL ID 
               MECHASOFT0@GMAIL.COM 



INTERFACING 4*4 HEXPAD/KEYPAD WITH 8051

Hello everyone!!!
interfacing a 4*4 keypad is a really difficult way to take input on micro controller BUT there is a very easy method to interface 4*4 keypad which does not require anything but a single encoder MM74C922.

SCHEMATIC:



MM74C922:

Many of us don't know about this IC what actually is the function of this chip?
It is the CMOS based IC which is capable of encoding an array of SPST (single pole single throw) switches key bouncing can also be reduced by using capacitor on key bounce pin .. 
this IC encode the 8 bit code into 4 bit and send it to micro controller.


CODE: 

Most of our work is done by MM74C922 now we just have to check what binary is being generated by pressing the keys on keypad. 

For Example :

  • If we press '7' on keypad '0000' will occur on output port. 

  • If we press '4' on keypad '0001' will occur on output port. 

  • If we press '1' on keypad '0010' will occur on output port. 
now we know what the user want to write by checking the binary output. 

If we want to write the number on LCD which is being pressed 

SCHEMATIC:

CODE:


org 00H
jmp 30H
org 30H

;---WRITING COMMANDS ON LCD ----

mov A,#38h     ;Use 2 lines and 5×7 matrix for LCD
acall com_wrt ; calling function to enter command on LCD 
mov A,#0Fh ; LCD ON, Cursor ON, Cursor blinking ON
acall com_wrt ; calling function to enter command on LCD 
mov A,#01h     ; clearing the LCD
acall com_wrt ; calling function to enter command on LCD  
mov A,#80h     ; Force cursor to the beginning of 1st line
acall com_wrt ; calling function to enter command on LCD 

;---CLEARING/SETTING PORTS/PINS----

mov P2,#00H ; clearing port 2 to eleminate garbage value
mov p1,#00H ; clearing port 2 to eleminate garbage value
setb P3.7 ; setting P3.7 to high (1) commanding MC to read when bit gets low (0)

;---START OF PROGRAM----


MAIN: 
clr A    ; clear garbage value from accumulator
call delay ; calling funtion for some delay
jb p3.7,main ; checking if there is any button pressed on hexpad if not jump to main
mov A,p0 ; copying  data of pressed button in accumulator
call delay ; calling funtion for some delay

cjne a,#0000b,chk1 ; checking if button pressed has a binary of 0000
mov A,#'7' ; if yes send "7" on data port 
call char_wrt ; calling function to display character on LCD


chk1:
cjne a,#0001b,chk2 ; checking if button pressed has a binary of 0001
mov A,#'4' ; if yes send "4" on data port 
call char_wrt ; calling function to display character on LCD

chk2:
cjne a,#0010b,chk3 ; checking if button pressed has a binary of 0010
mov A,#'1' ; if yes send "1" on data port 
call char_wrt ; calling function to display character on LCD


chk3:
cjne a,#0011b,chk4 ; checking if button pressed has a binary of 0011
jmp main

chk4:
cjne a,#0100b,chk5 ; checking if button pressed has a binary of 0100
mov A,#'8' ; if yes send "8" on data port 
call char_wrt ; calling function to display character on LCD

chk5:
cjne a,#0101b,chk6 ; checking if button pressed has a binary of 0101
mov A,#'5' ; if yes send "5" on data port 
call char_wrt ; calling function to display character on LCD

chk6:
cjne a,#0110b,chk7 ; checking if button pressed has a binary of 0110
mov A,#'2' ; if yes send "2" on data port 
call char_wrt ; calling function to display character on LCD


chk7:
cjne a,#0111b,chk8 ; checking if button pressed has a binary of 0111
mov A,#'0' ; if yes send "0" on data port 
call char_wrt ; calling function to display character on LCD

chk8:
cjne a,#1000b,chk9 ; checking if button pressed has a binary of 1000
mov A,#'9' ; if yes send "9" on data port 
call char_wrt ; calling function to display character on LCD

chk9:
cjne a,#1001b,chk10 ; checking if button pressed has a binary of 1001
mov A,#'6' ; if yes send "6" on data port 
call char_wrt ; calling function to display character on LCD

chk10:
cjne a,#1010b,chk11 ; checking if button pressed has a binary of 1010
mov A,#'3' ; if yes send "3" on data port 
call char_wrt ; calling function to display character on LCD

chk11:
cjne a,#1011b,chk12 ; checking if button pressed has a binary of 1011
mov A,#'=' ; if yes send "=" on data port 
call char_wrt ; calling function to display character on LCD

chk12:
cjne a,#1100b,chk13 ; checking if button pressed has a binary of 1100
mov A,#'/' ; if yes send "/" on data port 
call char_wrt ; calling function to display character on LCD

chk13:
cjne a,#1101b,chk14 ; checking if button pressed has a binary of 1101
mov A,#'*' ; if yes send "*" on data port 
call char_wrt ; calling function to display character on LCD

chk14:
cjne a,#1110b,chk15 ; checking if button pressed has a binary of 1110
mov A,#'-' ; if yes send "-" on data port 
call char_wrt ; calling function to display character on LCD

chk15:
cjne a,#1111b,return_main ; checking if button pressed has a binary of 1111
mov A,#'+' ; if yes send "+" on data port 
call char_wrt ; calling function to display character on LCD
return_main:
ljmp main  ; long jump to "main"

  ;---CHARACTER DISPLAYING MODULE----

char_wrt:  
acall delay  ; calling some time delay
setb p3.0  ; setting bit register select high 
clr p3.1  ; clearing bit to write data on LCD
mov p2,A  ; moving character to data port
setb p3.2  ; setting bit enable for starting clock
nop  ; time delay
nop  ; time delay
clr p3.2  ; clearing bit enable for ending clock
ret


;---COMMAND DISPLAYING MODULE----

com_wrt:
acall delay  ; calling some time delay
clr p3.0  ; setting bit register select high 
clr p3.1  ; clearing bit to write data on LCD
mov p2,A  ; moving character to data port
setb p3.2  ; setting bit enable for starting clock
nop  ; time delay
nop  ; time delay
clr p3.2  ; clearing bit enable for ending clock
ret

;---DELAY MODULE----

delay:
mov r6,#088h
loop:
djnz r5,$
djnz r6,loop
ret

end


LCD interfacing with 8051

Hello Everyone!!!
Many people face a lot of problems in interfacing LCD with 8051 micro controller, but in reality it is very easy and even fun to interface an LCD!!
16*2 LCD LM0161

WHAT DOES DIFFERENT PINS STAND FOR IN LCD????

First of all we will need to understand what does the pins in the LCD means...

VSS: To be provided with Ground.
VDD: To be provided with Source voltage.
VEE: Can be grounded or a potentiometer can be used to adjust the contrast of LCD.
RS: Is the register select pin decide either to write comment or data
RW: Is the read write pin decide either to write or read data
E: Is the enable pin used as clock
D0-D7 : Are the data pins messages are send on these pins.

There are two things to be written on LCD 
1) Command
2) Data 

What is a Command??? 

A command is a code for LCD that order it to set itself as per our requirements.
for example:
01H will clear your LCD
06H cursor will be incremented by 1 unit

How to write command?

In order to write a command we will need to :
  • clear the RS pin (RS=0)
  • clear the RW pin (RW=0)
  • Give clock on E pin with some delay
CODE:
For clearing LCD:

mov DATA,#01H
clr RS
clr RW
setb E
nop
nop
clr E

this code will clear you LCD many commands are available on internet.


Now What is a Data???

The data is simply the message we want to display on LCD.

How to write Data?

In order to write a data we will need to :

  • High the RS pin (RS=1)
  • clear the RW pin (RW=0)
  • Give clock on E pin with some delay
CODE:

For displaying letter 'A' on LCD:

mov DATA,#'A'
setb RS
clr RW
setb E
nop
nop
clr E

this code will display letter A on the LCD.


WRITING ON LCD!!!

As you are familiar with coding of LCD let us write our topic name on LCD!!!

SCHEMATIC:



CODE:

;---INIITIALIZING PORTS AND BITS----

rs bit P3.0     ; initializing port 3.0 as register select pin
rw bit P3.1      ; initializing port 3.1 as read/write pin
en bit P3.2     ; initializing port 3.2 as enaable pin
dat equ P2     ; initializing port 2 as data bus

org 00h  
jmp 30h
org 30h

;---WRITING COMMANDS ON LCD ----

mov A,#38h     ;Use 2 lines and 5×7 matrix for LCD
acall com_wrt ; calling function to enter command on LCD 
mov A,#0Fh ; LCD ON, Cursor ON, Cursor blinking ON
acall com_wrt ; calling function to enter command on LCD 
mov A,#01h     ; clearing the LCD
acall com_wrt ; calling function to enter command on LCD  
mov A,#80h     ; Force cursor to the beginning of 1st line
acall com_wrt ; calling function to enter command on LCD 

;---CLEARING/SETTING PORTS/PINS----


mov P2,#00H ; clearing port 2 to eleminate garbage value

;---START OF PROGRAM----

START:
call clear ; calling function to clear LCD

DISPLAY_MSG:
mov dptr,#msg ; copy message in data pointer to be displayed on LCD
call dmsg ; calling function to display message on LCD
DISPLAY_MSG1:
call nline
mov dptr,#msg1
call dmsg
jmp exit
clear:  ; LCD clearing module
mov a,#01h          ; clearing LCD 
acall com_wrt  ; calling function to enter command on LCD
ret  ; returning back 

dmsg:
call delay   ; calling some time delay
clr A   
movc a,@a+dptr   ; moves code byte of data located in program code ROM into Accumulator A
call char_wrt   ; calling function to write character 
inc dptr   ; incriment the value of data pointer by 1
jz display_msg1
jmp dmsg


;---CHARACTER DISPLAYING MODULE----

char_wrt:  
acall delay  ; calling some time delay
setb rs  ; setting bit register select high 
clr rw  ; clearing bit to write data on LCD
mov dat,A  ; moving character to data port
setb en  ; setting bit enable for starting clock
nop  ; time delay
nop  ; time delay
clr en  ; clearing bit enable for ending clock
ret      ; return back

;---COMMAND DISPLAYING MODULE----

com_wrt:
acall delay  ; calling some time delay
clr rs  ; rs=0 for writting comment
clr rw  ; rw=0 for writting comment
mov dat,A  ; copying acumulator in data port (p2)
setb en  ; en=1 for clock
nop  ; time delay
nop  ; time delay
clr en  ; en=0 for clock
ret  ; return to previous position

;---DELAY MODULE----

delay:
mov r6,#088h
loop:
djnz r5,$
djnz r6,loop
ret

nline:
mov a,#0c1h  ;next line
call com_wrt   ; calling function write comment on LCD
mov a,#0c0h  ;2nd line 1st position
call com_wrt  ; calling function write comment on LCD
ret


msg: db'LCD INTERFACING ',0
msg1: db' WITH OUR BLOG',0

Exit:
jmp msg1

end