If then


Closed Thread
Results 1 to 12 of 12

Thread: If then

  1. #1
    Join Date
    Nov 2007
    Location
    sri lanka
    Posts
    24

    Default If then

    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

  2. #2
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default Re: If then

    Good question! What PIC are you using? Which part of your code doesn't work? What kind of trouble shooting have you tried?
    http://www.scalerobotics.com

  3. #3
    Join Date
    Nov 2007
    Location
    sri lanka
    Posts
    24


    Did you find this post helpful? Yes | No

    Default Re: If then

    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.

  4. #4
    Join Date
    Nov 2007
    Location
    sri lanka
    Posts
    24


    Did you find this post helpful? Yes | No

    Default Re: If then

    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

  5. #5
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default Re: If then

    For the RX port, you would want to set TRISC to %10000000
    Last edited by ScaleRobotics; - 21st June 2012 at 05:29.
    http://www.scalerobotics.com

  6. #6
    Join Date
    Nov 2007
    Location
    sri lanka
    Posts
    24


    Did you find this post helpful? Yes | No

    Default Re: If then

    rx and tx working.send "AT" modam reply "OK"
    now case this program
    please send me sample

  7. #7
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default Re: If then

    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.

    Code:
    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
    http://www.scalerobotics.com

  8. #8
    Join Date
    Nov 2007
    Location
    sri lanka
    Posts
    24


    Did you find this post helpful? Yes | No

    Default Re: If then

    thank you i will try it

  9. #9
    Join Date
    Nov 2007
    Location
    sri lanka
    Posts
    24


    Did you find this post helpful? Yes | No

    Default Re: If then

    thank you sir
    it's really work
    thank u again
    ruwan.

  10. #10
    Join Date
    Nov 2007
    Location
    sri lanka
    Posts
    24


    Did you find this post helpful? Yes | No

    Default Re: If then

    how to send multiple number for same sms

  11. #11
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default Re: If then

    http://www.scalerobotics.com

  12. #12
    Join Date
    Nov 2007
    Location
    sri lanka
    Posts
    24


    Did you find this post helpful? Yes | No

    Default Re: If then

    HSEROUT[ "AT+CMGS="07190xxxx4071909xxx5"

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

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts