blufips
- 3rd March 2011, 04:18
Im just a beginer in programing and in making circuits... im currently doing my project... i used PIC16F877A and a GSM benqM23... the problem is the replying of my device... my project are compost of different sensors and when it detect it will send message to the given number and also you can send message to the device and it will reply to you... the sending part is ok but the reply part is not working... when i seperate the program for the reply it works well but when i combined it with the program of my sensor and sending it doesnt work... i dont know the problem if it is my program or my device... some one pls help me... here is my program...
my current program----> the reply part is not working
'************************************************* ***************
'* Name : UNTITLED.BAS *
'* Author : [select VIEW...EDITOR OPTIONS] *
'* Notice : Copyright (c) 2011 [select VIEW...EDITOR OPTIONS] *
'* : All Rights Reserved *
'* Date : 2/28/2011 *
'* Version : 1.0 *
'* Notes : *
'* : *
'************************************************* ***************
DEFINE OSC 4
DEFINE HSER_TXSTA 20h
DEFINE HSER_RCSTA 90h
DEFINE HSER_BAUD 9600
DEFINE HSER_CLROERR 1
DEFINE HSER_SPBRG 12
adcon1=7
cmcon=7
trisa=1
trisb=1
trisc=1
trisd=0
trise=1
y1 var byte[2]
y2 var byte[8]
pass1 var bit
pass2 var bit
pass3 var bit
a0 var porta.0
a1 var porta.3
a2 var porta.5
a3 var porte.2
b0 var portb.0
b1 var portb.1
b2 var portb.3
b3 var portb.4
b4 var portb.5
b5 var portb.6
b6 var portb.7
c0 var portc.0
c1 var portc.1
c2 var portc.2
d0 var portd.0
d1 var portd.1
d2 var portd.2
d3 var portd.3
d4 var portd.4
d5 var portd.5
d6 var portd.6
d7 var portd.7
e0 var porte.0
e1 var porte.1
y1[0]="0"
y1[1]="0"
pass1=0
pass2=0
pass3=0
a0=1
a1=1
a2=1
a3=1
b0=1
b1=1
b2=1
b3=1
b4=1
b5=1
b6=1
c0=1
c1=1
c2=1
e0=1
e1=1
portd=%11111111
pause 250
HSerout ["AT+CMGF=1",13]
Pause 500
HSEROUT ["AT+CMGDA=",34,"DEL ALL",34,13]
pause 500
portd=%00000000
main:
while 1
HSerin 5000, main2, [WAIT("SM")]
gosub reply
goto main
main2:
if a0=0 then
y1[0]="1"
y1[1]="6"
y2[0]="C"
y2[1]="R"
y2[2]="I"
y2[3]="T"
y2[4]="I"
y2[5]="C"
y2[6]="A"
y2[7]="L"
portd=%00000001
pause 500
portd=%00000000
pause 500
if pass1=0 then
gosub send1
pass1=1
pass2=0
pass3=0
endif
goto main
endif
if a1=0 then
y1[0]="1"
y1[1]="5"
y2[0]="A"
y2[1]="L"
y2[2]="R"
y2[3]="M"
y2[4]=32
y2[5]=32
y2[6]=32
y2[7]=32
portd=%00000011
pause 500
portd=%00000000
pause 500
if pass2=0 then
gosub send1
pass2=1
pass1=0
pass3=0
endif
goto main
endif
if a2=0 then
y1[0]="1"
y1[1]="4"
y2[0]="A"
y2[1]="L"
y2[2]="E"
y2[3]="R"
y2[4]="T"
y2[5]=32
y2[6]=32
y2[7]=32
portd=%00000111
pause 500
portd=%00000000
pause 500
if pass3=0 then
gosub send1
pass3=1
pass1=0
pass2=0
endif
goto main
endif
IF a3=0 then
y1[0]="1"
y1[1]="3"
goto main
endif
IF b0=0 then
y1[0]="1"
y1[1]="2"
goto main
endif
IF b1=0 then
y1[0]="1"
y1[1]="1"
goto main
endif
IF b2=0 then
y1[0]="1"
y1[1]="0"
goto main
endif
IF b3=0 then
y1[0]="9"
y1[1]=32
goto main
endif
IF b4=0 then
y1[0]="8"
y1[1]=32
goto main
endif
IF b5=0 then
y1[0]="7"
y1[1]=32
goto main
endif
IF b6=0 then
y1[0]="6"
y1[1]=32
goto main
endif
IF c0=0 then
y1[0]="5"
y1[1]=32
goto main
endif
IF c1=0 then
y1[0]="4"
y1[1]=32
goto main
endif
IF c2=0 then
y1[0]="3"
y1[1]=32
goto main
endif
IF e0=0 then
y1[0]="2"
y1[1]=32
goto main
endif
IF e1=0 then
y1[0]="1"
y1[1]=32
goto main
endif
wend
send1:
portd=%11111111
pause 500
portd=%00000000
pause 500
HSEROUT ["AT+CMGS=",34,"09166494457",34,13]
pause 1000
HSerout [y2[0],y2[1],y2[2],y2[3],y2[4],y2[5],y2[6],y2[7]," Water Level: ",y1[0],y1[1],26]
PAUSE 2000
portd=%01010101
pause 500
portd=%00000000
pause 500
return
reply:
portd=%00001111
pause 500
portd=%00000000
pause 500
HSEROUT ["AT+CMGS=",34,"09166494457",34,13]
portd.6=1
pause 1000
HSerout ["Water Level: ",y1[0],y1[1],26]
portd.5=1
pause 2000
return
my program for replying only----> it works well
'************************************************* ***************
'* Name : UNTITLED.BAS *
'* Author : [select VIEW...EDITOR OPTIONS] *
'* Notice : Copyright (c) 2010 [select VIEW...EDITOR OPTIONS] *
'* : All Rights Reserved *
'* Date : 11/19/2010 *
'* Version : 1.0 *
'* Notes : *
'* : *
'************************************************* ***************
DEFINE OSC 4
DEFINE HSER_TXSTA 20h
DEFINE HSER_RCSTA 90h
DEFINE HSER_BAUD 9600
DEFINE HSER_CLROERR 1
DEFINE HSER_SPBRG 12
adcon1=7
cmcon=7
'GSMBUFFER VAR BYTE[16]
'Caller VAR BYTE[13]
'GSMTime VAR BYTE[17]
trisa=%11111111
trisd=%00000000
text var byte[4]
text[0]="1"
text[1]="2"
text[2]="3"
text[3]="4"
portd=%111111111
pause 2000
HSerout ["AT+CMGF=1",13]
Pause 500
HSEROUT ["AT+CMGDA=",34,"DEL ALL",34,13]
PAUSE 3000
main:
WHILE 1
portd=%00000000
portd.0=1
PAUSE 500
portd=%00000011
pause 500
HSERIN 5000, main, [WAIT("SM")]
portd.7=1
pause 1000
HSEROUT ["AT+CMGS=",34,"09166494457",34,13]
portd.6=1
pause 1000
HSerout ["WATER LEVEL: ",text[0],text[1],"m",26]
portd.5=1
pause 2000
HSERIN 2000, main, [WAIT("OK")]
portd=%11111111
PAUSE 2000
HSEROUT ["AT+CMGD=1",13]
HSERIN [WAIT("OK")]
portd=%10101010
PAUSE 400
portd=%00000000
PAUSE 400
WEND
my current program----> the reply part is not working
'************************************************* ***************
'* Name : UNTITLED.BAS *
'* Author : [select VIEW...EDITOR OPTIONS] *
'* Notice : Copyright (c) 2011 [select VIEW...EDITOR OPTIONS] *
'* : All Rights Reserved *
'* Date : 2/28/2011 *
'* Version : 1.0 *
'* Notes : *
'* : *
'************************************************* ***************
DEFINE OSC 4
DEFINE HSER_TXSTA 20h
DEFINE HSER_RCSTA 90h
DEFINE HSER_BAUD 9600
DEFINE HSER_CLROERR 1
DEFINE HSER_SPBRG 12
adcon1=7
cmcon=7
trisa=1
trisb=1
trisc=1
trisd=0
trise=1
y1 var byte[2]
y2 var byte[8]
pass1 var bit
pass2 var bit
pass3 var bit
a0 var porta.0
a1 var porta.3
a2 var porta.5
a3 var porte.2
b0 var portb.0
b1 var portb.1
b2 var portb.3
b3 var portb.4
b4 var portb.5
b5 var portb.6
b6 var portb.7
c0 var portc.0
c1 var portc.1
c2 var portc.2
d0 var portd.0
d1 var portd.1
d2 var portd.2
d3 var portd.3
d4 var portd.4
d5 var portd.5
d6 var portd.6
d7 var portd.7
e0 var porte.0
e1 var porte.1
y1[0]="0"
y1[1]="0"
pass1=0
pass2=0
pass3=0
a0=1
a1=1
a2=1
a3=1
b0=1
b1=1
b2=1
b3=1
b4=1
b5=1
b6=1
c0=1
c1=1
c2=1
e0=1
e1=1
portd=%11111111
pause 250
HSerout ["AT+CMGF=1",13]
Pause 500
HSEROUT ["AT+CMGDA=",34,"DEL ALL",34,13]
pause 500
portd=%00000000
main:
while 1
HSerin 5000, main2, [WAIT("SM")]
gosub reply
goto main
main2:
if a0=0 then
y1[0]="1"
y1[1]="6"
y2[0]="C"
y2[1]="R"
y2[2]="I"
y2[3]="T"
y2[4]="I"
y2[5]="C"
y2[6]="A"
y2[7]="L"
portd=%00000001
pause 500
portd=%00000000
pause 500
if pass1=0 then
gosub send1
pass1=1
pass2=0
pass3=0
endif
goto main
endif
if a1=0 then
y1[0]="1"
y1[1]="5"
y2[0]="A"
y2[1]="L"
y2[2]="R"
y2[3]="M"
y2[4]=32
y2[5]=32
y2[6]=32
y2[7]=32
portd=%00000011
pause 500
portd=%00000000
pause 500
if pass2=0 then
gosub send1
pass2=1
pass1=0
pass3=0
endif
goto main
endif
if a2=0 then
y1[0]="1"
y1[1]="4"
y2[0]="A"
y2[1]="L"
y2[2]="E"
y2[3]="R"
y2[4]="T"
y2[5]=32
y2[6]=32
y2[7]=32
portd=%00000111
pause 500
portd=%00000000
pause 500
if pass3=0 then
gosub send1
pass3=1
pass1=0
pass2=0
endif
goto main
endif
IF a3=0 then
y1[0]="1"
y1[1]="3"
goto main
endif
IF b0=0 then
y1[0]="1"
y1[1]="2"
goto main
endif
IF b1=0 then
y1[0]="1"
y1[1]="1"
goto main
endif
IF b2=0 then
y1[0]="1"
y1[1]="0"
goto main
endif
IF b3=0 then
y1[0]="9"
y1[1]=32
goto main
endif
IF b4=0 then
y1[0]="8"
y1[1]=32
goto main
endif
IF b5=0 then
y1[0]="7"
y1[1]=32
goto main
endif
IF b6=0 then
y1[0]="6"
y1[1]=32
goto main
endif
IF c0=0 then
y1[0]="5"
y1[1]=32
goto main
endif
IF c1=0 then
y1[0]="4"
y1[1]=32
goto main
endif
IF c2=0 then
y1[0]="3"
y1[1]=32
goto main
endif
IF e0=0 then
y1[0]="2"
y1[1]=32
goto main
endif
IF e1=0 then
y1[0]="1"
y1[1]=32
goto main
endif
wend
send1:
portd=%11111111
pause 500
portd=%00000000
pause 500
HSEROUT ["AT+CMGS=",34,"09166494457",34,13]
pause 1000
HSerout [y2[0],y2[1],y2[2],y2[3],y2[4],y2[5],y2[6],y2[7]," Water Level: ",y1[0],y1[1],26]
PAUSE 2000
portd=%01010101
pause 500
portd=%00000000
pause 500
return
reply:
portd=%00001111
pause 500
portd=%00000000
pause 500
HSEROUT ["AT+CMGS=",34,"09166494457",34,13]
portd.6=1
pause 1000
HSerout ["Water Level: ",y1[0],y1[1],26]
portd.5=1
pause 2000
return
my program for replying only----> it works well
'************************************************* ***************
'* Name : UNTITLED.BAS *
'* Author : [select VIEW...EDITOR OPTIONS] *
'* Notice : Copyright (c) 2010 [select VIEW...EDITOR OPTIONS] *
'* : All Rights Reserved *
'* Date : 11/19/2010 *
'* Version : 1.0 *
'* Notes : *
'* : *
'************************************************* ***************
DEFINE OSC 4
DEFINE HSER_TXSTA 20h
DEFINE HSER_RCSTA 90h
DEFINE HSER_BAUD 9600
DEFINE HSER_CLROERR 1
DEFINE HSER_SPBRG 12
adcon1=7
cmcon=7
'GSMBUFFER VAR BYTE[16]
'Caller VAR BYTE[13]
'GSMTime VAR BYTE[17]
trisa=%11111111
trisd=%00000000
text var byte[4]
text[0]="1"
text[1]="2"
text[2]="3"
text[3]="4"
portd=%111111111
pause 2000
HSerout ["AT+CMGF=1",13]
Pause 500
HSEROUT ["AT+CMGDA=",34,"DEL ALL",34,13]
PAUSE 3000
main:
WHILE 1
portd=%00000000
portd.0=1
PAUSE 500
portd=%00000011
pause 500
HSERIN 5000, main, [WAIT("SM")]
portd.7=1
pause 1000
HSEROUT ["AT+CMGS=",34,"09166494457",34,13]
portd.6=1
pause 1000
HSerout ["WATER LEVEL: ",text[0],text[1],"m",26]
portd.5=1
pause 2000
HSERIN 2000, main, [WAIT("OK")]
portd=%11111111
PAUSE 2000
HSEROUT ["AT+CMGD=1",13]
HSERIN [WAIT("OK")]
portd=%10101010
PAUSE 400
portd=%00000000
PAUSE 400
WEND