;Interactive Voice Response System For College Automation (IVRS) ; ;---------==========----------==========---------=========--------- VISIT www.8051projects.info for more free projects ;---------==========----------==========---------=========--------- INCLUDE reg_52.pdf RB0 EQU 000H ; Select Register Bank 0 RB1 EQU 008H ; Select Register Bank 1 ... STD EQU P1.3 ;DTMF OUTPUT Q3 EQU P1.2 Q2 EQU P1.1 Q1 EQU P1.0 Q0 EQU P3.7 RELAY EQU P1.6 RING EQU P1.4 DSEG ; This is internal data memory ORG 20H ; Bit adressable memory DTMF: DS 1 D0 BIT DTMF.0 D1 BIT DTMF.1 D2 BIT DTMF.2 D3 BIT DTMF.3 COUNT: DS 1 CSEG ; Code begins here ;---------==========----------==========---------=========--------- ; PROCESSOR INTERRUPT AND RESET VECTORS ;---------==========----------==========---------=========--------- ORG 0000H ; Reset MOV SP,#60H MOV PSW,#RB0 CLR RELAY ;switch off relay MOV TMOD,#20H ; initilize timer 1 for baud rate generation for serial port MOV TH1,#0FDH ;select 9600bps MOV SCON,#50H SETB TR1 ;start timer MAIN: SETB STD ;make STD pin as input SETB RING ; make ring signal pin as input JB RING,$ ;chk Tele Ring AJMP PICK_PHONE ;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% PICK_PHONE: CALL DELAYS ;Wait for 4 rings MOV R2,#0AH ;delay program TP3: MOV R0,#0FFH TP2: MOV R1,#0FFH TP1: JNB RING,SDCD1 DJNZ R1,TP1 DJNZ R0,TP2 DJNZ R2,TP3 AJMP DISCONN SDCD1: SETB RELAY ;take the phone CALL DELAY MOV A,#'A' ;INFORM COMPUTER to start process TOOP: CALL TRANS SETB STD MOV R2,#90H ;wait for DTMF signal TA3: MOV R0,#0FFH TA2: MOV R1,#0FFH TA1: JB STD,SDCD2 DJNZ R1,TA1 DJNZ R0,TA2 DJNZ R2,TA3 AJMP DISCONN ;if no signal for 5min disconnect the phone SDCD2: CALL READ MOV A,DTMF CJNE A,#0CH,TOOPS AJMP DISCONN TOOPS: CJNE A,#0AH,RFT1 MOV A,#30H AJMP TOOP RFT1: CJNE A,#0BH,RFT2 MOV A,#40H AJMP TOOP RFT2: ADD A,#30H AJMP TOOP TRANS: MOV SBUF,A ;send dialled data to PC JNB TI,$ CLR TI RET ;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DELAYS: MOV R2,#0AH ;delay program EP3: MOV R0,#0FFH EP2: MOV R1,#0FFH EP1: NOP DJNZ R1,EP1 DJNZ R0,EP2 DJNZ R2,EP3 RET ;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DISCONN: MOV A,#'B' ;disconnect telephone CALL TRANS ; sent char B to pc that telephone is disconnected CLR RELAY CALL DELAY CALL DELAY AJMP MAIN ;jump to main progrm ;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ; READ DTMF TONES ;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% READ: MOV DTMF,#00H ;read DTMF code from the IC SETB Q0 SETB Q1 SETB Q2 SETB Q3 JNB Q0,VB1 SETB D0 VB1: JNB Q1,VB2 SETB D1 VB2: JNB Q2,VB3 SETB D2 VB3: JNB Q3,VB4 SETB D3 VB4: JB STD,$ RET ;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DELAY: ;delay program MOV R0,#0FFH REP2: MOV R1,#0FFH REP1: NOP DJNZ R1,REP1 DJNZ R0,REP2 RET ;*********************************************************************** END