PDA

View Full Version : If then



kumara
- 19th June 2012, 16:00
dear all


TRISB=%00000000
PORTB=%00000000
DEFINE OSC 4
DEFINE HSER_TXSTA 20h
DEFINE HSER_RCSTA 90h
DEFINE HSER_BAUD 2400
DEFINE HSER_SPBRG 25
DEFINE HSER_CLROERR 1


TRISB=%00000000
PORTB=%00000000
trisd=%00001111
portd=%00000000

GSM_CHECK:
portb=%11110000
HSEROUT ["AT",13]
HSERIN 5000, GSM_CHECK, [WAIT("OK")]
pause 200
PORTb=%00000000
BEGIN:
high PORTB.6
if PORTD.0 = 1 then SEND_SMS0
IF PORTD.1 = 1 then SEND_SMS1
if PORTD.0 = 0 then SEND_SMS2
IF PORTD.1 = 0 then SEND_SMS3
PAUSE 1000
LOW PORTB.6
GOTO BEGIN

SEND_SMS0:
HIGH PORTB.7
HSEROUT ["at+cmgs=",34,"0719099xxx",34,13]
PAUSE 1000
HSEROUT ["unit ,1, triped",26]
HSERIN 5000, BEGIN, [WAIT("OK")]
LOW PORTB.7
end
SEND_SMS1:
HIGH PORTB.6
HSEROUT ["at+cmgs=",34,"0719099xxx",34,13]
PAUSE 1000
HSEROUT ["unit,2, triped",26]
HSERIN 5000, BEGIN, [WAIT("OK")]
LOW PORTB.6
end
SEND_SMS2:
HIGH PORTB.5
HSEROUT ["at+cmgs=",34,"0719099xxx",34,13]
PAUSE 1000
HSEROUT ["unit ,1, syncronus",26]
HSERIN 5000, BEGIN, [WAIT("OK")]
LOW PORTB.5
end
SEND_SMS3:
HIGH PORTB.4
HSEROUT ["at+cmgs=",34,"0719099xxx",34,13]
PAUSE 1000
HSEROUT ["unit ,2,syncronus",26]
HSERIN 5000, BEGIN, [WAIT("OK")]
LOW PORTB.4
End

this coode not working.some body can help me

ScaleRobotics
- 19th June 2012, 16:17
Good question! What PIC are you using? Which part of your code doesn't work? What kind of trouble shooting have you tried?

kumara
- 21st June 2012, 02:20
portd.0 and portd.1 inputs get syncronus breaker lcosed and open cotact point.its repeat send sms.i can't anderstand how to write.

kumara
- 21st June 2012, 02:34
i get inputs my syncronous breaker closed and open point.if portd 0=1 then send sms0 it repeat .my pic is 16f877a.
thank you

ScaleRobotics
- 21st June 2012, 05:27
For the RX port, you would want to set TRISC to %10000000

kumara
- 21st June 2012, 13:03
rx and tx working.send "AT" modam reply "OK"
now case this program
please send me sample

ScaleRobotics
- 21st June 2012, 17:34
I received a PM defining the problem a little better:


dear sir
can u help me this project
my modem ok
send AT
reply OK
this program send sms repitly how to stop it
thank you


So, you only want to send sms on change of state for portd.0 or portd.1 ?



port d.0


Here are some untested modifications to your code. It should test for a change condition on portd.0 and portd.1. I know you said you only wanted d.0, but you can always remove the rest.



TRISB=%00000000
PORTB=%00000000
DEFINE OSC 4
DEFINE HSER_TXSTA 20h
DEFINE HSER_RCSTA 90h
DEFINE HSER_BAUD 2400
DEFINE HSER_SPBRG 25
DEFINE HSER_CLROERR 1
PortDStatus var byte ' variable for storing status of portd

TRISB=%00000000
PORTB=%00000000
trisd=%00001111
portd=%00000000

GSM_CHECK:
portb=%11110000
HSEROUT ["AT",13]
HSERIN 5000, GSM_CHECK, [WAIT("OK")]
pause 200
PORTb=%00000000
'get initial status
PortDStatus.0 = PORTD.0
PortDStatus.1 = PORTD.1

BEGIN:
high PORTB.6
if PORTD.0 != PortDStatus.0 then 'sensed change in PORTD.0
pause 10 'debounce 10 ms
PortDStatus.0 = PORTD.0 'save new status for PORTD.0
if PORTD.0 = 1 then
gosub SEND_SMS0 'send new status report
else 'PORTD.0 = 0
gosub SEND_SMS2
endif
endif

if PORTD.1 != PortDStatus.1 then 'sensed change in PORTD.1
pause 10
PortDStatus.1 = PORTD.1 'save new status for PORTD.1
IF PORTD.1 = 1 then
gosub SEND_SMS1
else 'PORTD.1 = 0
gosub SEND_SMS3
endif
endif

PAUSE 1000
LOW PORTB.6
GOTO BEGIN

SEND_SMS0:
HIGH PORTB.7
HSEROUT ["at+cmgs=",34,"0719099xxx",34,13]
PAUSE 1000
HSEROUT ["unit ,1, triped",26]
HSERIN 5000, BEGIN, [WAIT("OK")]
LOW PORTB.7
return

SEND_SMS1:
HIGH PORTB.6
HSEROUT ["at+cmgs=",34,"0719099xxx",34,13]
PAUSE 1000
HSEROUT ["unit,2, triped",26]
HSERIN 5000, BEGIN, [WAIT("OK")]
LOW PORTB.6
return

SEND_SMS2:
HIGH PORTB.5
HSEROUT ["at+cmgs=",34,"0719099xxx",34,13]
PAUSE 1000
HSEROUT ["unit ,1, syncronus",26]
HSERIN 5000, BEGIN, [WAIT("OK")]
LOW PORTB.5
return

SEND_SMS3:
HIGH PORTB.4
HSEROUT ["at+cmgs=",34,"0719099xxx",34,13]
PAUSE 1000
HSEROUT ["unit ,2,syncronus",26]
HSERIN 5000, BEGIN, [WAIT("OK")]
LOW PORTB.4
return

end

kumara
- 22nd June 2012, 03:11
thank you i will try it

kumara
- 22nd June 2012, 06:06
thank you sir
it's really work
thank u again
ruwan.

kumara
- 23rd June 2012, 04:14
how to send multiple number for same sms

ScaleRobotics
- 23rd June 2012, 06:06
Does this help? http://www.picbasic.co.uk/forum/showthread.php?t=16386

kumara
- 23rd June 2012, 07:12
HSEROUT[ "AT+CMGS="07190xxxx4071909xxx5"

but this code don't work
please ex plane this code sample