Professional Documents
Culture Documents
Program of Put Coin and Draw Power
Program of Put Coin and Draw Power
$mod51
; p3.0
; p3.1
; p3.2
; p3.7
; p1.0
; p1.1
indicator
; p1.4 to p1.7
; r0,r1
; r2
; r3
approx)
;(r4
; r5
development
;r6
; r7
start: ;
count upto 5
count for 7seg display left justified
org 000h
sjmp start
org 040h
-INITIALISATION STARTmov r3,#000h ;count is 0
mov r4 , #000h;flag reset
movr5 ,#000h;mono on flag reset
mov r2,#000h;coin count 0
mov r6,#oo5h;counter set to 5
mov r7,#oooh;
setb p3.0; no coin detected
setbp3.2; mono output detected set high
clr p3.7; coin detected LED off
clr p1.1
;relay de-energised
Setb p1.0
mov a,p1
an1 a,#oofh ;extract LS portin keep intact
orl a,b
;count ored in a
Movp1, a
;-PUTTING COUNT ON 7 SEG OVERsjmp tst count
updt r3: mova,r3
add a,#005h
clr c
mov r3,a ;added in r3
mov a,r2; count no of coins in r2
inc a
clr c
cjne a,#10,max
mov a, #9
max:mov r2,a
acall coin ;
EVERY TIME COIN SENSED
sjmp tstcount
tstpwrsw: jnb p3.1 ,swpwron
clr p1.1
sjmp coindet
swpw ron : setb p1.1 ; relay on
jnb p3.2,coindet ; is delay running ? if yes go and sense coin
dec r3
dec r6 ;
reduce count from 5 set in r6
mov a,r6
cjne a,#000h, bypss r2
dec r2
;1
subtracted from r2 for every 5 in r3
mov a,r2
jz min
rl a
rl a
rl a
rl a
clr c
mov b,a
mov a,b1
an1 a,#00fh
orl a,b
mov p1,a
mov r6 , #005h; initial count of 5 in r6
bypssr2: acall delay
acall delay
acall delay
acall delay
acall delay
acall delay
acall delay
acall delay
trigr: clrp1.0
acall delay
;
mono triggered
setbp1.0
ajmp tstcount
min: mov p1,#01h
ajmp tstcount
;-ROUTINESdelay: mov r0,#0c8h
loop2:mov r1,#ofah
loop1:nop
nop
nop
djnz r1,loop1 ;loop1 approx 5 X 200=1msec
djnz r0,loop2 ;loop2 250 X1msec=250msec
ret
coin : setb p3.7
acall delay
acall delay
acall delay
acall delay
clr p3.7
acall delay
acall delay
acall delay
acall delay
ret
end