Monday, July 26, 2010
Access Control System
Automatic Traffic Control System
The intelligent and cooperative set-up of actuation and its linkage to the central control system is vital for avoiding traffic jams and accidents. Moreover, environmental costs (eg pollution) can be decreased.
The design of the traffic control system can be evaluated in two steps – synthesis and analysis. Several models and multiple control strategies exist, and engineers must decide between them using a priori knowledge of the real system. Previously collected information can help to choose the appropriate model, parameters, measurement and control methodologies to create the optimal solution.
Wednesday, July 21, 2010
Difference b/w microprocessor and microcontroller
Microcontroller on the other hand is designed to operate with minimal external circuitry using a control program in ROM. The instruction set is simpler in a microcontroller compared to that in microprocessor as instruction are needed to move code and data between internal memory and ALU.
Sunday, July 18, 2010
LCD Interface
Schematic

Circuit Description
Above is the quite simple schematic. The LCD panel's Enable and Register Select is connected to the Control Port. The Control Port is an open collector / open drain output. While most Parallel Ports have internal pull-up resistors, there are a few which don't. Therefore by incorporating the two 10K external pull up resistors, the circuit is more portable for a wider range of computers, some of which may have no internal pull up resistors.
We make no effort to place the Data bus into reverse direction. Therefore we hard wire the R/W line of the LCD panel, into write mode. This will cause no bus conflicts on the data lines. As a result we cannot read back the LCD's internal Busy Flag which tells us if the LCD has accepted and finished processing the last instruction. This problem is overcome by inserting known delays into our program.
The 10k Potentiometer controls the contrast of the LCD panel. Nothing fancy here. As with all the examples, I've left the power supply out. You can use a bench power supply set to 5v or use a onboard +5 regulator. Remember a few de-coupling capacitors, especially if you have trouble with the circuit working properly.
The 2 line x 16 character LCD modules are available from a wide range of manufacturers and should all be compatible with the HD44780. The one I used to test this circuit was a Powertip PC-1602F and an old Philips LTN211F-10 which was extracted from a Poker Machine! The diagram to the right, shows the pin numbers for these devices. When viewed from the front, the left pin is pin 14 and the right pin is pin 1.
Programming - Source Code
/* LCD Module Software */
/* 17th May 1997 */
/* Copyright 1997 Craig Peacock */
/* WWW - http://www.senet.com.au/~cpeacock */
/* Email - cpeacock@senet.com.au */
/* */
/* Register Select must be connected to Select Printer (PIN 17) */
/* Enable must be connected to Strobe (PIN1) */
/* DATA 0:7 Connected to DATA 0:7 */
#include
#include
#define PORTADDRESS 0x378 /* Enter Your Port Address Here */
#define DATA PORTADDRESS+0
#define STATUS PORTADDRESS+1
#define CONTROL PORTADDRESS+2
void main(void)
{
char string[] = {"Testing 1,2,3 "
"It' Works ! "};
char init[10];
int count;
int len;
init[0] = 0x0F; /* Init Display */
init[1] = 0x01; /* Clear Display */
init[2] = 0x38; /* Dual Line / 8 Bits */
outportb(CONTROL, inportb(CONTROL) & 0xDF); /* Reset Control Port - Make sure Forward Direction */
outportb(CONTROL, inportb(CONTROL) | 0x08); /* Set Select Printer (Register Select) */
for (count = 0; count <= 2; count++)
{
outportb(DATA, init[count]);
outportb(CONTROL,inportb(CONTROL) | 0x01); /* Set Strobe (Enable)*/
delay(20); /* Larger Delay for INIT */
outportb(CONTROL,inportb(CONTROL) & 0xFE); /* Reset Strobe (Enable)*/
delay(20); /* Larger Delay for INIT */
}
outportb(CONTROL, inportb(CONTROL) & 0xF7); /* Reset Select Printer (Register Select) */
len = strlen(string);
for (count = 0; count < len; count++)
{
outportb(DATA, string[count]);
outportb(CONTROL,inportb(CONTROL) | 0x01); /* Set Strobe */
delay(2);
outportb(CONTROL,inportb(CONTROL) & 0xFE); /* Reset Strobe */
delay(2);
}
}
Above is the source code to get this example running. It's been written for Borland C, so if you are using a Microsoft compiler, then you will have to change the outportb() function to outp() and inportb() to inp().
The LCD panel requires a few instructions to be sent, to order to turn on the display and initialise it. This is what the first for loop does. These instructions must be sent to the LCD's Instruction Register which is controlled by the Register Select (Pin 4). When pin 4 is low the instruction register is selected, thus when high the data register must be selected. We connect this to the Parallel Port's Select Printer line which happens to be hardware inverted. Therefore if we write a '1' to bit 3 of the Control Register the Select Printer line goes low.
We want to first send instructions to the LCD module. Therefore the Register Select line must be low. As it is hardware inverted, we will want to set bit 3 of the Control Register to '1'. However we don't want to upset any other bits on the Control Port. We achieve this by reading the Control Port and OR'ing 0x80 to it. e.g. outportb(CONTROL, inportb(CONTROL) | 0x08); This will only set bit 3.
After we place a data byte on the data lines, we must then signal to the LCD module to read the data. This is done using the Enable line. Data is clocked into the LCD module on the high to low transition. The Strobe is hardware inverted, thus by setting bit 0 of the Control Register we get a high to low transition on the Strobe line. We then wait for a delay, and return the line to a high state ready for the next byte.
After we initialize the LCD Module, we want to send text to it. Characters are sent to the LCD's Data Port, thus we want to clear bit 3. Once again we must only change the one bit, thus we use outportb(CONTROL, inportb(CONTROL) & 0xF7);. Then we set up another for loop to read a byte from the string and send it to the LCD panel. This is repeated for the length of the string.
The delays should be suitable for most machines. If the LCD panel is not initializing properly, you can try increasing the delays. Likewise if the panel is skipping characters, e.g. Tst ,2. On the other hand, If the LCD module is repeating characters e.g. TTTeessttiinngg then you may have a faulting Enable connection. Check your Enable to Strobe connection.
Thursday, July 15, 2010
Automated car parking system
Design
A display is provided at the ground floor which is a counter that displays number of cars in each floor. It informs whether the floor is ful or not. Cars can be lifted up and down! Lift is controlled by stepper motor. An indicator with a green and red LED is kept in all the floors to indicate whether the lift is busy or is it ready to take the car up or down. If the red LED glows that means the lift is already engaged and the person has to wait for the green LED to glow. In this project we have provided three floors of a building for car parking. Maximum storage capacity of each floor is given as ten. Storage capacity can be changed according to the requirement.
When the car enters the lift, the LDR detects its presence and sends a signal to glow RED LED indicating that the lift is busy. It also sends a signal to motor which makes the motor to rotate. After RED LED glows the lift will take the person and the car up to the floor where the space for parking is available. (For VIP it will be the third floor). When the lift reaches the first floor, the processor compares the filled amount to that of the already fed capacity of that floor, and if it finds that the first floor is fully filled , it goes to the second floor and thus the procedure stops here. As soon as a car is placed in a particular floor, the display counter at the ground floor increments as to indicate the floor capacity has decreased by one. After the lift places the car in a particular floor, it comes back to its normal position and that time, the motor that drives it , also stops. Now processor sends signal to glow GREEN LED indicating that lift is free.
When a person needs to come down from a particular floor to ground floor, he is expected to focus the headlight onto the LDR placed in that floor. Now sensor section sends signal to motor that the lift has to be send back to that particular floor and sends a signal to glow RED LED indicating that the lift is busy. As soon as the lift reaches that particular floor car should come inside the lift, the display counter at the ground floor decrements by one as to indicate the floor capacity has increased by one. Lift comes back to its normal position and that time, the motor that drives it, also stops. Now processor sends signal to glow GREEN LED indicating that lift is free.
If there no parking taking place, the processor carries out the job according to the following priority:-
1. It checks whether any password is entered.
2. It checks whether any car is entered to lift.
3. It checks whether any car headlight is pressed in front of LDR placed in each floor.
It is like a round robin system.
3. Hardware description:
Introduction to 8051 Microcontroller:
The 8051 microcontroller generic part number actually includes a whole family of microcontrollers that have numbers ranging from 8031 to 8751.The block diagram of the 8051 shows all of the features unique to microcontrollers:
1. Internal ROM and RAM
2. I/O ports with programmable pins
3. Timers and counters
4. Serial data communication
The block diagram also shows the usual CPU components program counter, ALU, working registers, and the clock circuits.
The 8051 architecture consists of these specific features:
1. 8 bit CPU with registers A and B
2. 16 bit PC &data pointer (DPTR)
3. 8 bit program status word (PSW)
4. 8 bit stack pointer(SP)
5. Internal ROM or EPROM (8751)of 0(8031)to 4k(8051)
6. Internal RAM of 128 bytes.
7. 4 register banks , each containing 8 registers
8. 80 bits of general purpose data memory
9. 32 input/output pins arranged as four 8 bit ports:P0-P3
10. Two 16 bit timer/counters:T0-T1
11. Two external and three internal interrupt sources
12. Oscillator and clock circuits
A pin out of the 8051 packaged in a 40 pin DIP is shown below.
Automated car parking system-Abstract
Monday, May 10, 2010
Metro Train Using MicroController
Saturday, May 8, 2010
Biometric Access System
Adaptable Virtual Keyboard
Adaptable Virtual Keyboard could be called next generation keyboard. Ordinary keyboards have keys with specific size and specific imprints on them. The interactivity and usability of keyboards would surely increase if it could display a symbol for the current function associated with the key or if the language of the keyboard could be changed.
Microsoft aimed at making the virtual keyboard but the layout and functions of the keyboard cannot be changed. The system uses 3D modelling to detect a keystroke and is processor intensive. Special hardware to project the “qwerty” layout and infrared light which is required in detection undermines the sole objective of reducing hardware components and cost reduction.
Thursday, April 29, 2010
Automatic Temperature Indicator-Program
; matirx keyboard with connections on p2 port
;rows are connected to p2.0 to p2.2
;columns are connected to p2.4 to p2.7
;Lcd connected at p1 with Controls pins
;at rs-p3.5,rw-p3.4,en-p3.3
sda equ p0.1
scl equ p0.0
rs equ p3.5
rw equ p3.4
en equ p3.3
lcd equ p1
lcd_busy equ p1.7
key_brd equ p2
th equ 50h
tl equ 51h
ascii_store equ 40h
delimiter equ 20h
delay_count equ 23h
temperature_store equ 30h
temp_result equ 35h
LCD_str equ 2ah
;Flags
th_flag equ 7fh
tl_flag equ 7eh
temp_flag equ 7dh
org 0000h
mov sp,#60h
lcall ini
clr th_flag
clr tl_flag
mov th,#40
mov tl,#37
mov dptr,#Msg0
acall msg_read
mov delay_count,#40 ;for 2-sec time
acall time ; $$$$$$$$$$$$$$$
value_enter:
mov r7,#01h
acall command
mov dptr,#Msg1 ;show th
acall read
mov a,th
mov r1,#LCD_str
acall bin2ascii
inc r1
acall tim_display
mov r7,#87H
acall command
mov dptr,#Msg2 ;show th
acall read
mov a,tl
mov r1,#LCD_str
acall bin2ascii
inc r1
acall tim_display
;till here default values are shown
;into nezt line show following
mov r7,#0c0h
acall command
mov dptr,#Msg5
acall msg_read
scan0:
mov key_brd,#0f0h ;bcoz upper 4
mov a,key_brd ;are connected to colu
cjne a,#0f0h,mode_check0
sjmp scan0
;**************** detecting rows
mode_check0:
acall delay1
mov a,key_brd
cjne a,#0f0h,mode_check1
sjmp scan0
mode_check1:
acall delay
acall delay1
mov key_brd,#0ffh
mov key_brd,#0fbh
mov a,key_brd
cjne a,#0fbh,enter_check
ajmp scan0
enter_check: ;This is enter button
jb acc.6,mod43
ajmp temp_conversion_start
ljmp scan0
mod43: ;This is clear button
jnb acc.7,clear_press
ljmp scan0
clear_press:
mov r7,#01h
acall command
mov dptr,#Msg1 ;show th
acall read
mov r7,#38h
acall command
mov r7,#0eh
acall command
mov r7,#06h
acall command
mov r7,#0c0h
acall command
setb th_flag
; mov r6,#3
ajmp forward
tl_edit:
mov r7,#01h
acall command
mov dptr,#Msg2 ;show tl
acall read
mov r7,#0c0h
acall command
setb tl_flag
forward:
mov lcd,#00h
scan:
mov key_brd,#0f0h ;bcoz upper 4 are
mov a,key_brd ;connected to column
cjne a,#0f0h,row
sjmp scan
;*************** detecting rows
row:
acall delay1
mov a,key_brd
cjne a,#0f0h,row111
sjmp scan
row111:
acall delay
acall delay1
mov key_brd,#0ffh
mov key_brd,#11111110b
mov a,key_brd
orl a,#0fh
cjne a,#0ffh,row1
mov key_brd,#0ffh
mov key_brd,#0fdh
mov a,key_brd
cjne a,#0fdh,row2
mov key_brd,#0ffh
mov key_brd,#0fbh
mov a,key_brd
cjne a,#0fbh,row3
ajmp scan
;**********
row1:
jb acc.4,c2
mov r7,#'0'
acall display
sjmp scan
c2:
jb acc.5,c3
mov r7,#'1'
acall display
sjmp scan
c3:
jb acc.6,c4
mov r7,#'2'
acall display
sjmp scan
c4:
mov r7,#'3'
acall display
sjmp scan
;****************
row2:
jb acc.4,c22
mov r7,#'4'
acall display
ljmp scan
c22:
jb acc.5,c32
mov r7,#'5'
acall display
ljmp scan
c32:
jb acc.6,c42
mov r7,#'6'
acall display
ljmp scan
c42:
mov r7,#'7'
acall display
ljmp scan
;****************
row3:
jb acc.4,c23
mov r7,#'8'
acall display
ljmp scan
c23:
jb acc.5,c33
mov r7,#'9'
acall display
ljmp scan
c33:
jb acc.6,c43
ajmp test ;This is enter button
ljmp scan
c43:
;This is clear button
;not used here
ljmp scan
*******************
test:
mov r7,#04h
acall command
acall ready
acall read_add1
clr c
mov b,#0c0h
subb a,b
mov r0,a
mov r1,#ascii_store
acall ready
acall read_data
repeat:
inc r1
acall ready
acall read_data
mov @r1,a
djnz r0,repeat
mov delimiter,r1
inc delimiter
;conversion routine ;bank 1 used
setb psw.3
mov r5,#00h ;used for msb
mov r6,#00h ;used for storing the lsb result
mov r0,#0ah
mov r2,#1
mov r3,#10
mov r4,#100
mov r1,#(ascii_store+1)
here: clr a
mov a,r1
cjne a,delimiter,convert
ajmp break ; read till there
convert:
mov a,@r1
anl a,#0fh
mov b,@r0
mul ab
mov r7,a
xch a,b
cjne a,#00h,hiii
looo:
mov a,r6 ;result of add
addc a,r7
jc for
con: mov r6,a
inc r1
inc r0
ajmp here
break:
clr psw.3
**********************
jb tl_flag,tl_save
clr c
mov a,0eh ;0eh is the add of r6 of bank1
cjne a,#7dh,th_check
th_check:
jnc error_msg ;a> or = 125 show error
mov th,0eh ;if c then save
clr th_flag
ajmp tl_edit
error_msg:
mov r7,#01h
acall command
jb tl_flag,tl_error
mov dptr,#Msg3
acall msg_read
acall time
ajmp clear_press ;again enter th
tl_error:
mov dptr,#Msg4
acall msg_read
acall time
ajmp tl_edit ;again enter tl
***************portion of the conversion routine
hiii:
add a,r5
mov r5,a
ajmp looo
for:
inc r5
ajmp con
tl_save:
clr c
mov a,0eh ;0eh is the add of r6 of bank2
cjne a,th,tl_check
tl_check:
jnc error_msg ;a> or = th show error
mov tl,0eh ;0eh is the add of r6 of bank2
clr tl_flag
;now we have to show the saved values on
;LCD & wait for enter to be pressed
ajmp value_enter
;___________________________
temp_conversion_start:
mov r0,#th
acall delay10
acall i2cstart
mov a,#90h
acall i2cwrite
mov a,#0ach
acall i2cwrite
acall delay10
mov a,#02h
acall i2cwrite
acall delay10
acall i2cstart
mov a,#90h
acall i2cwrite
mov a,#0a1h
acall i2cwrite
acall delay10
mov a,th ;#28h
acall i2cwrite
mov a,#00h
acall i2cwrite
acall delay10
acall i2cstart
mov a,#90h
acall i2cwrite
mov a,#0a2h
acall i2cwrite
acall delay10
mov a,tl ;#24h
acall i2cwrite
mov a,#00h
acall i2cwrite
acall delay10
acall i2cstop
clr temp_flag ;temp flag
mov r7,#01h
acall command
mov dptr,#Msg
acall read
mov temperature_store,#00h
here1:
acall temp ;temp read by this routine
jb temp_flag,EEE
setb temp_flag
mov temperature_store,a
ajmp here1
EEE:
cjne a,temperature_store,make_equal
ajmp here1
make_equal:
mov temperature_store,a
acall conversion
mov r7,#8bh
acall command
acall string
sjmp here1
; ************************
temp:
acall i2cstart
mov a,#90h
acall i2cwrite
;*****************************
mov a,#0eeh
acall i2cwrite
; start temp conversion
acall i2cstop
acall i2cstart
mov a,#90h
acall i2cwrite
mov a,#0aah
acall i2cwrite
; read last read temp
acall i2cstart
mov a,#91h
acall i2cwrite
acall i2cread
acall i2cstop
ret
i2cstart:
setb sda
acall delayone
setb scl
acall delayone
clr sda
clr scl
ret
i2cstop:
clr scl
clr sda
setb scl
acall delayone
setb sda
mov c,sda
ret
i2cwrite:
mov r0,#08h
i2cwrite_loop:
rlc a
mov sda,c
setb scl
acall delayone
clr scl
djnz r0,i2cwrite_loop
mov c,sda
setb scl
acall delayone
clr scl
ret
i2cread:
mov c,sda
mov r0,#8
rlc a
i2cread_loop:
setb scl
mov c,sda
rlc a
acall delayone
clr scl
djnz r0,i2cread_loop
ret
delayone:
mov r1,#100
loopa:
djnz r1,loopa
ret
read_data: ;data is stored in the r0 register
mov lcd,#0ffh
setb rs ;to select data register
setb rw
clr en
setb en
mov a,lcd
clr en
ret
read_add1:
mov lcd,#0ffh
clr rs
setb rw
clr en
setb en
mov a,lcd
clr en
orl a,#80h
ret
read_add:
push acc
mov lcd,#0ffh
clr rs
setb rw
clr en
setb en
mov a,lcd
clr en
orl a,#80h
cjne a,#8fh,out
mov r7,#0c0h
acall command
out:
pop acc
ret
conversion:
push acc
mov a,temperature_store
mov r0,#(temperature_store+1)
conloop:
mov b,#10
div ab
orl 0f0h,#30h
mov @r0,0f0h
inc r0
cjne a,#00h,conloop
dec r0
mov r1,#temp_result;35h
conloop1:
mov a,@r0
mov @r1,a
dec r0
inc r1
cjne r0,#temperature_store,conloop1
mov @r1,#'$'
pop acc
ret
string:
push acc
mov r0,#temp_result;30h
strloop:
mov a,@r0
mov r7,a
cjne a,#'$',continue
mov r7,#' '
acall display
pop acc
ret
continue:
acall display
inc r0
sjmp strloop
bin2ascii:
mov @r1,#'$'
dec r1
rep:
mov b,#10
div ab
orl 0f0h,#30h
mov @r1,0f0h
dec r1
cjne a,#00h,rep
ret
tim_display:
brij: mov 07h,@r1
cjne r7,#'$',shoe
ret
shoe:
acall display
inc r1
ajmp brij
command:
acall ready
mov lcd,r7
clr rs
clr rw
setb en
clr en
ret
display:
acall ready
mov lcd,r7
setb rs
clr rw
setb en
clr en
ret
ready:
clr en
mov lcd,#0ffh
clr rs
setb rw
wait:
clr en
setb en
jb lcd_busy,wait
clr en
ret
ini:
mov r7,#38h
acall delay1
acall delay1
acall command
mov r7,#38h
acall delay1
acall command
mov r7,#38h
acall delay1
acall command
mov r7,#0eh
acall command
mov r7,#01h
acall command
mov r7,#06h
acall command
mov r7,#80h
acall command
ret
delay10:
push acc
mov tmod,#01h
mov tl0,#10h
mov th0,#27h ;1050=2710h
mov tcon,#00h
setb tr0
wait12: jnb tf0,wait12
clr tr0
pop acc
ret
delay1:
push 07h
push 06h
mov r6,#100
loop24: mov r7,#100
loop23: djnz r7,loop23
djnz r6,loop24
pop 06h
pop 07h
ret
;**********
delay:
push acc
push 00h
mov r0,#02h
loopr:
mov b,#0a0h
loopb:
mov a,#0fah
loopa12:
dec a
jnz loopa12
djnz 0f0h,loopb
djnz r0,loopr
pop 00h
pop acc
ret
time:
push 00h
mov r0,30h ;30h contain counter
mov tmod,#01h
repeat1: mov tcon,#00h
mov th0,#3ch
mov tl0,#0aah
setb tr0
wait1: jnb tf0,wait1
clr tr0
djnz r0,repeat1
pop 00h
ret
msg_read:
push acc
push 07h
nex: clr a
movc a,@a+dptr
mov r7,a ;r7 is used for passing parameter to display
cjne a,#'0',aga
sjmp down
aga: acall read_add
acall display
inc dptr
sjmp nex
down:
pop 07h
pop acc
ret
read:
nex1:
clr a
movc a,@a+dptr
cjne a,#'0',aga1
sjmp down1
aga1:
mov r7,a
acall display
acall delay1
inc dptr
sjmp nex1
down1:
ret
Msg: db 'Temprature ','0'
Msg0: db 'Welcome To Auto Temp Controller','0'
Msg1: db 'TH ','0'
Msg2: db 'Tl ','0'
Msg3: db 'Error: TH > or = 125','0'
Msg4: db 'Error: Tl > or = TH','0'
Msg5: db 'Enter for cont.','0'
end
Metro Train-Program
The coding of the metro train prototype is given in the assembly language. The programme main routines are the routines for running of stepper motor in forward direction and in reverse direction. the routines for this purpose are stepperf and stepperb. The routines display and command are used in conjunction with LCD display.
; Program for a stepper having connected at p2(from p2.0 to p2.3) & to show
Message on the LCD
data equ p1
busy equ p1.7
rs equ p3.5
rw equ p3.4
en equ p3.3
bzr equ p0.2
ledf equ p0.0
ledb equ p0.1
org 400h
show0: db 'Welcome To All','0'
show1: db 'Current Station','0'
show2: db 'Next Station','0'
show3: db 'Roorkee','0'
show4: db 'Saharanpur','0'
Show5: db 'Meerut','0'
org 0000h
ajmp main
org 0003h
test: mov c,p3.2
jnc halt
setb bzr
reti
halt:
clr bzr ;till zero blow on the bzr
ajmp test
main:
mov ie,#00h
setb ea
setb ex0
here:
mov p2,#00h
acall ini
mov dptr,#show0
acall read
clr ledf ;p1.0
acall delay
mov a,#01h
acall command; Now make memory clear cursor home
mov dptr,#show1
acall read
setb ex0 ;#############
mov a,#0c0h
acall command
mov dptr,#show3
acall read
acall delay ;Stopage1 time 3 sec rookee
acall delay
clr bzr
acall delay
mov a,#01h
acall command
mov dptr,#show2
acall read
mov a,#0c0h
acall command
mov dptr,#show4
acall read
setb bzr
acall delay10
acall stepperf
mov a,#01h
acall command
mov dptr,#show1
acall read
mov a,#0c0h
acall command
mov dptr,#show4
acall read
acall delay ;Stopage2 time 3 sec shsar
acall delay
clr bzr
acall delay
mov a,#01h
acall command
mov dptr,#show2 ;display ne
acall read
mov a,#0c0h
acall command
mov dptr,#show5
acall read
setb bzr
acall delay10
acall stepperf
mov a,#01h
acall command
mov dptr,#show1
acall read
mov a,#0c0h
acall command
mov dptr,#show5
acall read
acall delay ;Stopage2 time 3 sec Meerut
acall delay
clr bzr
acall delay
setb ledf ; p1.0 ;off led at
p1.0 for forward journey
clr ledb ; p1.1 ; 0n Led
for back ward journey
mov a,#01h
acall command
mov dptr,#show2 ;display ne shar
acall read
mov a,#0c0h
acall command
mov dptr,#show4
acall read
setb bzr
acall delay10
acall stepperb
mov a,#01h
acall command
mov dptr,#show1
acall read
mov a,#0c0h
acall command
mov dptr,#show4
acall read
acall delay ;Stopage2 time 3 sec shsar
acall delay
clr bzr
acall delay
mov a,#01h
acall command
mov dptr,#show2 ;display ne roor
acall read
mov a,#0c0h
acall command
mov dptr,#show3
acall read
setb bzr
acall delay10
acall stepperb
mov a,#01h
acall command
mov dptr,#show1
acall read
mov a,#0c0h
acall command
mov dptr,#show3
acall read
setb ledb ;p1.1
ljmp here
;routine for stepper motor
; Delay Routine ;one sec delay
delay:
push acc
push 00h
push 01h
push p0
push p1
mov r0,#0eh
loopr:
mov a,#0ffh
loopb:
mov b,#0ffh
loopa: djnz b,loopa
djnz 0e0h,loopb
djnz r0,loopr
pop p1
pop p0
pop 01h
pop 00h
pop acc
ret
;dlay stepper
delays:
push acc
push 00h
push 01h
push p0
push p1
mov a,#0ffh
loopa1: mov b,#0fh
loopb1: djnz b,loopb1
djnz 0e0h,loopa1
pop p1
pop p0
pop 01h
pop 00h
pop acc
ret
delay10:
mov tmod,#01h
mov tcon,#00h
mov tl0,#0f0h
mov th0,#0f8h
setb tr0
no: jnb tf0,no
clr tr0
clr tf0
ret
;=============== Routine to read data from prog mem
read:
nex: clr a
movc a,@a+dptr
cjne a,#'0',aga
sjmp down
aga: acall display
inc dptr
sjmp next
down:
ret
;================ stepper routine
stepperf:
push acc
push p1
mov a,#88h
mov r1,#04h
loop1: mov r0,#0e0h
loop: mov p2,a
acall delays
rr a
djnz r0,loop
djnz r1,loop1
pop p1
pop acc
ret
stepperb:
push acc
push p1
mov a,#88h
mov r1,#04h
loop12:
mov r0,#0e0h
loop0: mov p2,a
acall delays
rl a
djnz r0,loop0
djnz r1,loop12
pop p1
pop acc
ret
;*******************************************************
;LCD strobe subroutines
ini: mov a,#38h
acall command
mov a,#38h
acall command
mov a,#38h
acall command
mov a,#38h
acall command
mov a,#0eh
acall command
mov a,#06h
acall command
mov a,#01h
acall command
mov a,#80h
acall command
ret
command:
acall ready
mov data,a
clr rs
clr rw
setb en
clr en
ret
display:
acall ready
mov data,a
setb rs
clr rw
setb en
clr en
ret
ready:
clr en
mov data,#0ffh
clr rs
setb rw
wait: clr en
setb en
jb busy,wait
clr en
Ret
End
Voting Machine-Program
$mod51
in equ p0
scl bit p2.4
sda bit p2.5
org 0h
ljmp main1
org 0003h
ljmp intrupt
org 0020h
main1: setb p3.2
mov ie,#81h
setb tcon.0
mov tmod,#20h
mov scon,#50h
mov th1,#-3
setb tr1
setb scl
setb sda
setb p2.6
mov r5,#00h
mov r6,#00h
mov r7,#00h
main: mov in,#11111110b
mov a,in
anl a,#11111110b
cjne a,#11111110b,j
sjmp main
j: mov a,in
jb acc.1,j2
inc r5
clr p2.6
acall delay1
acall delay1
setb p2.6
busy1: jnb p0.1,busy1
ljmp eewrite
sjmp main
j2: jb acc.2,j3
inc r6
clr p2.6
acall delay1
acall delay1
setb p2.6
busy2: jnb p0.2,busy2
ljmp Iewrite
sjmp main
j3: jb acc.3,j4
inc r7
clr p2.6
acall delay1
acall delay1
setb p2.6
busy3: jnb p0.3,busy3
ljmp IIwrite
j4: sjmp main
intrupt:
mov dptr,#mydata0
acall routs
acall delay_15ms
mov r1,#05h
acall step
mov dptr,#mydata1
acall routs
acall delay_15ms
mov r1,#06h
acall step
mov dptr,#mydata2
acall routs
acall delay_15ms
mov r1,#07h
acall step
reti
eewrite: mov a,#10100000b
acall i2cstart
acall i2cwrite
mov a,#05h
mov 30h,a
acall i2cwrite
mov a,r5
acall i2cwrite
acall i2cstop
acall jkl
ljmp main
Iewrite: mov a,#10100000b
acall i2cstart
acall i2cwrite
mov a,#06h
mov 30h,a
acall i2cwrite
mov a,r6
acall i2cwrite
acall i2cstop
acall jkl
ljmp main
IIwrite: mov a,#10100000b
acall i2cstart
acall i2cwrite
mov a,#07h
mov 30h,a
acall i2cwrite
mov a,r7
acall i2cwrite
acall i2cstop
acall jkl
ljmp main
i2cstart: setb sda
acall delay
setb scl
acall delay
clr sda
clr scl
ret
i2cstop: clr scl
clr sda
setb scl
acall delay
setb sda
mov c,sda
ret
i2cwrite: mov r0,#08h
i2cwrite_loop: rlc a
mov sda,c
setb scl
acall delay
clr scl
djnz r0,i2cwrite_loop
mov c,sda
setb scl
acall delay
clr scl
ret
i2cread: mov c,sda
mov r0,#8
rlc a
i2cread_loop: setb scl
mov c,sda
rlc a
acall delay
clr scl
djnz r0,i2cread_loop
ret
delay: mov r4,#100
loop: djnz r4,loop
ret
delay1: mov r4,#0ffh
jll: mov r1,#0ffh
jl: djnz r1,jl
djnz r4,jll
ret
jkl: mov a,#10100000b
acall i2cstart
acall i2cwrite
mov a,#00h
acall i2cwrite
acall i2cread
acall i2cstop
ret
mydata0: db 'VOTER NO.1=',0
mydata1: db ' VOTER NO.2=',0
mydata2: db ' VOTER NO.3=',0
routs: clr a
movc a,@a+dptr
jz here
acall display
inc dptr
sjmp routs
here: acall delay_15ms
ret
delay_15ms: mov r3,#4h
loop14: mov r2,#0ffh
loop1: djnz r2,loop1
djnz r3,loop14
ret
display: mov sbuf,a
loopi: jnb ti,loopi
clr ti
ret
step: mov a,#10100000b
acall i2cstart
acall i2cwrite
mov a,r1
acall i2cwrite
acall i2cstop
acall i2cstart
mov a,#10100001b
acall i2cwrite
acall i2cread
acall i2cstop
mov 33h,a
mov a,r1
cjne a,#05h,kl
mov 34h,33h
mov a,33h
acall sett
ret
kl: cjne a,#06h,kl1
mov 35h,33h
mov a,33h
acall sett
ret
kl1: mov 36h,33h
mov a,33h
acall sett
ret
sett: da a
mov 37h,a
anl a,#0f0h
swap a
add a,#30h
mov 50h,a
acall display
mov a,37h
anl a,#0fh
add a,#30h
mov 51h,a
acall display
ret
end
;================ End Of Program Code =====================
Component’s List for Project:
AT89C51 1
MAX 232 IC 1
IC 24C02 1
R S 232 Cable (Male, Female) 1
LED 2
Resistances 10K 2
Crystal Oscillator. (11.0592 MHz) 1
2 pin Switch 5
9- pin DB Connector 1
Diode 1n4007 4
IC Base (8Pin, 16 pin, 40Pin) 1 each
Power chord 1
Capacitor 1000Microfarad/ 25v 1
Capacitor 10 Microfarad / 25v 4
Voltage Regulator L7805CN 1
Transformer (9-0-9) 1
Thursday, April 22, 2010
Voting machine with PC using the Hyper Terminal communication system
Construction and working of Circuit:
The figure above shows the basic circuit diagram of the electronic voting machine system using microcontroller AT89C51. The power supply for the circuit is regulated by the IC7805 and supplied to different parts of the unit. 24C02 is the memory storage IC. The microcontroller unit (MCU) reads the data from the IC 24C02 Via MAX-232 IC the serial communication IC. The MAX -232 IC transfers the data stored in the 24C02 to the secondary memory of the computer via RS 232 cable which is used to setup a communication medium between the computer and the voting machine. The HyperTerminal is the software which is used to view the votes of the user on the computer. The communication between the voting machine and the computer is established with the help of this software. The functions of each section of the circuit are explained in the following sections.
Power Supply:
The power supply unit consists of a step-down transformer (230V AC primary to 0-9V, 250mA secondary), bridge rectifier and voltage regulator. The output of the transformer is fed to bridge rectifier diodes D1 through D4 (each IN4007). The ripple from the output bridge rectifier is filtered by capacitor C1 and fed to regulator IC7805. The regulated output is given to the memory unit, microcontroller unit and data transfer unit, respectively.
When the switch S1 is closed, LED1 glows to indicate the presence of power in the system.
Data Storage:
While the power is put on and as the Vcc arrives the microcontroller unit and the current is provided to the memory IC the program starts to run after resetting the circuit. The user votes to the particular nominee whichever it likes to and then the data provided by the user is stored in the memory IC 24C02. The data stored in the memory IC is then accessed afterwards with the help of the serial communication IC MAX-232 and can be viewed on the computer via a HYPERLINK communication software.
To prevent data corruption and inadvertent write operations during power up, a Power On Reset (POR) circuit is implemented. Until the VCC voltage has reached the POR threshold value, the internal reset is active, all operations are disabled and the device will not respond to any command. In the same way, when VCC drops down from the operating voltage to below the POR threshold value, all operations are disabled and the device will not respond to any command. A stable VCC must be applied before applying any logic signal.
Addressing:
The chip address of 24C02 comprises internal preset code nibble '1001' (binary) followed by internally configurable address pins/bits A2, A1 and A0. The eighth bit of the address byte is determined by the type of operation (either read or write) that is to be performed. For writing to the device the eight bit is '0' and for reading from the device the eighth bit is '1'. In our case, A2, A1 and A0 pins are grounded and hence the device address for writing is '1001000b' or 90 (hex) and for reading the device address is '10010001b' or 91 (hex).
Command Set:
Complete command instruction set for accessing various internal registers as well as for starting and stopping of conversion process are given in Table. For understanding the exact sequence in which start bit, address byte, acknowledgement bit, command byte and data bytes are to be sent along the I2C bus, please refer to the datasheet of 24C02, wherein these aspects have been explained in proper detail. This will help in understanding the contents of the main program.
Microcontroller Unit:
Microcontroller AT89C51 (IC2) is a 40 pin IC from Atmel. Its pin details are shown in the pin description diagram. Like AT89C51, it also belongs to the 8031/8051 family. Microcontroller AT89C52 has a 256*8 bit internal random- access memory (RAM), eight interrupt sources and 8KB of flash memory compared to 128*8 -bit internal RAM, six interrupt sources and 4KB flash memory in AT89C51. By combining a versatile 8-bit CPU with flash memory on a monolithic chip, Atmel AT89C51is a powerful, highly cost-effective solution to many embedded control applications. Ports 0 and 2 are 8-bit bidirectional input/ output (I/O) ports. These ports haven't been used in this temperature indicator. Port 1 is an 8-bit bidirectional I/O port with internal pull-ups. Ports 1.0 through 1.7 are connected to pins 7 through 14 of the LCD. Port 1 output buffers can sink/ source four TTl inputs. Port 3 is a 8-bit bidirectional I/O port with internal pull-ups. Ports 3.0 and 3.1 of IC2 are connected to serial clock line (SCL) and serial data line (SDA) of IC3, respectively. Port 3 output buffers can sink/source four TTL inputs. A 12MHz crystal oscillator is connected to XTAL1 and XTAL2 pins for operation of the microcontroller. A high pulse on RST pin (pin 9) while the oscillator is running resets the microcontroller. In this circuit, this pin is connected to +Vcc through capacitors C5 (10uF, 16V). The external-access enable pin (EA) is connected to +Vcc for internal program executions. This pin also receives the 12V programming enable voltage (Vpp) during flash programming when 12V program is selected
TESTING:
Visualization Test:
When the fabrication process is completed & all the components have been mounted perfectly the visualization testing is performed. In this testing the circuit is scanned simply by the eyes & not by the help of any instrument. It to ensure that the soldering is perfect and there is no loose connection between the components.
Pre-heating Test:
This test is performed to check the heat tolerance of the components. In this the circuit is provided power supply and left for some time. After a interval of time it is checked that if there is any component get faulty component specially for IC’s.
Component’s List for Project:
AT89C51 1
MAX 232 IC 1
IC 24C02 1
R S 232 Cable (Male, Female) 1
LED 2
Resistances 10K 2
Crystal Oscillator. (11.0592 MHz) 1
2 pin Switch 5
9- pin DB Connector 1
Diode 1n4007 4
IC Base (8Pin, 16 pin, 40Pin) 1 each
Power chord 1
Capacitor 1000Microfarad/ 25v 1
Capacitor 10 Microfarad / 25v 4
Voltage Regulator L7805CN 1
Transformer (9-0-9) 1
Home Security System
Automatic Temperature Indicator
The figure above shows the basic block diagram of the temperature indicator system using microcontroller AT89C52. The power supply for the circuit is regulated by the IC7805 and supplied to different parts of the unit. DS1621 is the temperature sensor chip. The microcontroller unit (MCU) reads the temperature from the sensor. The temperature data is compared with certain user-define temperature values and processed inside the MCU as per the program and then sent to the LCD display.The functions of each section of the circuit are explained in the following sections.
Power Supply:
The power supply unit consists of a step-down transformer (230V AC primary to 0-9V, 250mA secondary), bridge rectifier and voltage regulator. The output of the transformer is fed to bridge rectifier diodes D1 through D4 (each IN4007). The ripple from the output bridge rectifier is filtered by capacitor C1 and fed to regulator IC7805. The regulated output is given to the temperature sensor, microcontroller unit and LCD module, respectively.
When the switch S1 is closed, LED1 glows to indicate the presence of power in the system.
Temperature Sensor:
Temperature sensor chip DS1621 (IC3) is an 8-pin DIP IC. The pin details of DS1621 are shown in its diagram and the internal block diagram in figure-3. The chip can measure temperatures from -55 to 125 degree Celsius in 0.5 degree Celsius increments, which are read as 9-bit values. It can operate off 2.7V to 5.5V. Data is read /written via a 2-wire serial interface. Pins 1 and 2 of the temperature IC are connected to pins 11 and 10 of the microcontroller, respectively. The thermal alarm output (Tout) of IC DS1621 activates when the temperature exceeds user defined high temperature TH. The output remains active until the temperature drops below user-defined low temperature Tl. User-defined temperature settings are stored in the non-volatile memory. Temperature settings and temperature readings are all communicated to/from IC DS1621 over a 2-wire serial cable. The most significant bit (MSB) of the data is transmitted first and the last significant bit (LSB) is transmitted last.
Addressing:
The chip address of DS1621 comprises internal preset code nibble '1001' (binary) followed by internally configurable address pins/bits A2, A1 and A0. The eighth bit of the address byte is determined by the type of operation (either read or write) that is to be performed. For writing to the device the eight bit is '0' and for reading from the device the eighth bit is '1'. In our case, A2, A1 and A0 pins are grounded and hence the device address for writing is '1001000b' or 90 (hex) and for reading the device address is '10010001b' or 91 (hex).
Configuration/Status register:
This register can be accessed for reading or writing by issuing command byte AC(hex) from the master (82C52). This register is particularly required if DS1621 is used for thermostat control, since it contains flag bits THF (high-temperature flag) which are set to '1' when temperature crosses the respective limits earlier written into TH and TL registers. It also contains the flag bit (done), which is set to '1' when results of conversion are available after issuing of start conversion command EE(hex). The other bits of configuration register are defined. 'NVB' is the non-volatile memory busy flag, '1' is to write to an E2 memory cell in progress, '0' indicates that non-volatile memory is not busy, 'POL' is non-volatile output polarity bit ('1'=active high and '0' = active low) and '1shot' is one-shot mode. A copy to E2 may take up to 10ms. If 1shot is '1', DS1621 will perform one temperature conversion upon reception of the start convert T protocol. If 1shot is '0', DS1621 will continuously perform temperature conversions. This bit is non-volatile.
Command Set:
Complete command instruction set for accessing various internal registers as well as for starting and stopping of conversion process are given in Table. For understanding the exact sequence in which start bit, address byte, acknowledgement bit, command byte and data bytes are to be sent along the I2C bus, please refer to the datasheet of DS1621, wherein these aspects have been explained in proper detail. This will help in understanding the contents of the main program.
Microcontroller Unit:
Microcontroller AT89C52 (IC2) is a 40 pin IC from Atmel. Its pin details are shown in the pin description diagram. Like AT89C51, it also belongs to the 8031/8051 family. Microcontroller AT89C52 has a 256*8 bit internal random- access memory (RAM), eight interrupt sources and 8KB of flash memory compared to 128*8 -bit internal RAM, six interrupt sources and 4KB flash memory in AT89C51. By combining a versatile 8-bit CPU with flash memory on a monolithic chip, Atmel AT89C52 is a powerful, highly cost-effective solution to many embedded control applications. Ports 0 and 2 are 8-bit bidirectional input/ output (I/O) ports. These ports haven't been used in this temperature indicator. Port 1 is an 8-bit bidirectional I/O port with internal pull-ups. Ports 1.0 through 1.7 are connected to pins 7 through 14 of the LCD. Port 1 output buffers can sink/ source four TTl inputs. Port 3 is a 8-bit bidirectional I/O port with internal pull-ups. Ports 3.0 and 3.1 of IC2 are connected to serial clock line (SCL) and serial data line (SDA) of IC3, respectively. Port 3 output buffers can sink/source four TTL inputs. A 12MHz crystal oscillator is connected to XTAL1 and XTAL2 pins for operation of the microcontroller. A high pulse on RST pin (pin 9) while the oscillator is running resets the microcontroller. In this circuit, this pin is connected to +Vcc through capacitors C5 (10uF, 16V). The external-access enable pin (EA) is connected to +Vcc for internal program executions. This pin also receives the 12V programming enable voltage (Vpp) during flash programming when 12V program is selected
TESTING:
Visualization Test:
When the fabrication process is completed & all the components have been mounted perfectly the visualization testing is performed. In this testing the circuit is scanned simply by the eyes & not by the help of any instrument. It to ensure that the soldering is perfect and there is no loose connection between the components.
Pre-heating Test:
This test is performed to check the heat tolerance of the components. In this the circuit is provided power supply and left for some time. After a interval of time it is checked that if there is any component get faulty component specially for IC’s.
Applications:
1. This system can be placed near computer processors for heat sensing.
2. Placed near heat sensitive devices to indicate the temperature.
3. This system can interfaced with computers and temperature can be controlled.
Program:
http://projects-applications.blogspot.com/2010/04/automatic-temperature-indicator-program.html
Component’s List for Project:
AT89C51 1
DS-1621 1
2 Line LCD 1
Buzzer 1
Transistor BC 548 1
LED 1
Resistances 10K 5
Resistance 470 ohm 5
33picofarad Ceramic Disk Capacitor 2
Crystal Oscillator. (12 MHz) 1
Mini Switch 13
10K Pot (Preset) 1
Diode 1n4007 4
IC Base (8Pin, 40Pin) 1 each
Relimate (5 pin and 2 pin) 1 each
Relimate (16pin) 2
Power chord 1
Capacitor 100Microfarad/ 25v 1
Capacitor 10 Microfarad / 25v 1
Voltage Regulator IC 7805 1
Transformer (9-0-9) 1
Metro Train Using MicroController-Project
Projects summary:
In this project we try to give the same prototype for this type of trains. We are using microcontroller 89c51 as CPU. The motion of the train is controlled by the stepper motor, for displaying the message in the train we are using intelligent LCD display of two lines. The train is designed for three stations, named as Roorkee, Saharanpur, and Meerut. The stoppage time for every station is 3sec and time to travel from one station to another is 6sec.there is a LCD display for showing various message in the train for passengers. There are indicators, which are used to show the train direction i.e. UP path and DOWN path .before stopping at the station, the train blows the buzzer. it also includes an emergency brakes system due to which the train stops as soon as the brakes are applied and resumes journey when he emergency situation is over.
IC’s used:-
AT89c51 microcontroller
Uln 2003 chip
Resistor’s used:-
R1 10 kilo-ohms
R 4.7 kilo-ohms
R3 220 ohms
R4 220 ohms
Vr 10 kilo-ohms
Capacitor’s used:-
C 33 pico farads (ceramic disk)
Other component’s required:-
Two line LCD display
Unipolar stepper motor
Two light emitting diode’s
Crystal oscillator 12MHz
Fabrication tools required:-
Permanent marker
Etching solution (ferrous chloride)
Drilling machine
Cutter
Soldering machine