gsm modem with 16f877a


Closed Thread
Results 1 to 14 of 14
  1. #1
    Join Date
    Nov 2007
    Location
    sri lanka
    Posts
    24

    Default gsm modem with 16f877a

    dear friends
    i want to interface M1206B gsm modem with pic 16f877a.modem with pc ok.i can send sms using hyperterminal.pc with pic ok i can display "at"
    but pic and modem not suport.i have chang baundrate but donot work.i have find som post but i can't do it.please help me
    thank you


    ' Initialization
    TRISB=%00000000
    PORTB=%00000000

    'Definitions
    DEFINE OSC 4
    DEFINE HSER_TXSTA 20h
    DEFINE HSER_RCSTA 90h
    DEFINE HSER_BAUD 2400
    DEFINE HSER_SPBRG 25

    BEGIN:
    PORTB = 0
    HIGH PORTB.7
    PAUSE 1000
    LOW PORTB.7
    HIGH PORTB.6
    HSerout ["AT",13,10] 'TEST COMMUNICATION
    HSERIN 5000,begin,[WAIT("OK")]
    HIGH PORTB.5
    PAUSE 500
    GOTO begin

    'END
    End

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

    Default Re: gsm modem with 16f877a

    any body help me..

  3. #3
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,795

    Default Re: gsm modem with 16f877a

    1. Is your modem communicating with a PC at the specified speed? You seem to use 2400 baud rate...

    2. Do the trick with a second serial port, two resistors (experiment from 10K down to 1K which ever works) to pick the Rx and Tx lines an monitor on a PC terminal. You will see if the commands are received and what the modem answers.

    3. Post the results to check here.

    Ioannis

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

    Default Re: gsm modem with 16f877a

    1.it's works 2400 boundrate with pc.

    2.i can't undertand this trick.

  5. #5
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,795

    Default Re: gsm modem with 16f877a

    Modem PIC
    Tx -----------X-----------------Rx
    Rx ------X----|-----------------Tx
    | |
    1k 1k
    | |
    PC |----|
    Rx-------X---X

    Hope this helps you understand.

    Ioannis

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

    Default Re: gsm modem with 16f877a

    Mr Ioannis now i can send sms (i have 1 mistake rx and tx chang)but now i want to do read sms and high led.please help methank you

  7. #7
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,795

    Default Re: gsm modem with 16f877a

    This example subroutine is for Wavecom. You have to check the manual of your GSM device for the correct commands.
    Also this example supposes that the GSM device responds with ASCII characters and not with numbers. OK instead of 0 (zero).

    Code:
    GSM_Subroutine:
    HSerout ["AT+CMGL=",34,"ALL",34,13] 'Check if there is new SMS. 34 is for " symbol
    Hserin 5000,err,[wait(10,13,10),str command\2]
    if command[0]="O" then return	'If response was just OK, then there was no SMS
    if command[0]="+" then goto read_sms 'If response started with + sign then there was some sms
    
    err:
    return
    
    read_sms:
    Lcdout com,line1,"Reading SMS",rep " "\4
    for l=0 to 5:command[l]=0:next l    'Clear buffer
    GoSub Mobile_Number      'get mobile number from setup, to check correct admin number
    HSerout ["AT+CMGL=",34,"ALL",34,13]  '"ALL" is for Wavecom module. Read all SMS 
    ' Read Caller ID etc. The timeout value in the HSERIN statement is important.
    ' it takes some time before the phone replies to the AT+CMGL command
    HSerin 5000,ex_sms4,[wait("READ"),skip 4,waitstr command\10,skip 27,STR command\6\13] 'Number is waitstr command\10
    LCDOut com,line1,"Read 1 SMS",rep " "\4,com,line2,"Command: ",str command\6
    
    sms_delete:
    HSerout ["AT+CMGD=1,4",13]			'Delete all messages
    LCDOut com,line1,"Deleting SMS":pause 150
    HSerin 15000,ex_sms2,[wait("OK")]     'Wait for OK (null)
    LCDOut com,line1,"Deleted SMS ":Pause 1000
    GoTo lcd_cls
    
    ex_sms2:    'No new message or timeout error
    LCDOut com,line2,"Error",rep " "\11:Pause 1000
    GoTo sms_chk
    
    ex_sms3:
    LCDOut com,line2,"SMS Check Error":Pause 1000
    GoTo sms_delete
    
    ex_sms4:    'Wrong Number!
    LCDOut com,line2,"Error phone Nbr":Pause 1000
    GoTo sms_delete
    I repeat again, study your GSM AT commands before attempting anything.
    Ioannis

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

    Default Re: gsm modem with 16f877a

    Mr.Ioannis

    I HAVE FIND SOME CODE ABOUT AND I WROTE SOME CODE "AT+CMGD"
    I SEND TO MODEM TO SMS "A" BUT NOT TURN ON PORTB.6

    WHAT'S THE WRONG THIS CODE HELP ME
    ' Def
    define OSC 4
    DEFINE HSER_SPBRG 25
    DEFINE HSER_TXSTA 20h
    DEFINE HSER_RCSTA 90h
    DEFINE HSER_BAUD 2400
    DEFINE HSER_CLROERR 1

    sms VAR BYTE[16]

    I VAR BYTE

    'Check sms

    begin:
    HIGH PORTB.7
    HSerout ["AT",13,10]' start comm
    HSERIN 2000,begin,[WAIT("OK")]
    LOW PORTB.7


    query:
    HSEROUT["AT+CMGL=",34,"REC READ",34,13,10]' filter for query
    HSERIN 5000,query,[WAIT("REC READ"),skip 41, STR sms\16\13]
    HIGH PORTB.5
    PAUSE 200
    LOW PORTB.5
    I=0

    WHILE I <> 13' count until 13
    if sms[i]=$44 THEN ' searching for letter A ?
    GOTO turnon:
    ELSE
    GOTO back
    I=I+1
    ENDIF
    WEND
    turnon:
    High PortB.6
    pause 1000
    HSerout ["AT+CMGD=1",13,10]
    low portb.6
    GOTO QUERY
    back:
    HIGH PORTB.4
    HSerout ["AT+CMGD=1",13,10]
    PAUSE 100
    LOW PORTB.4
    GOTO QUERY
    END

    xxxxx.

  9. #9
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,795

    Default Re: gsm modem with 16f877a

    Are you sure the x y z modem that you have not study yet, is working at 2400 ?

    I am sorry but cannot guess. Nor I have the magic ball to tell me what you have, how it must be set-up. It is your job to do it.

    Ioannis

  10. #10
    Join Date
    Feb 2010
    Posts
    17

    Default Re: gsm modem with 16f877a

    Hi,
    First make sure you connect the pic rx and tx trough 10k resitor to the modem's rx and tx pin, Then you need to tie the handhaking pins together on the modem side.
    Start with pin 7 and 8 tied together and see if u get some data if not then tie pins 4 AND 6.Most modems required handshaking by tieing these pins the modem will be always ready to send and receive other wise it will sit and wait. Good luck hope this will help.

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

    Default Re: gsm modem with 16f877a

    my sms project
    Name:  DSC05877.JPG
Views: 3476
Size:  35.2 KB
    3 input and 3 out put

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

    Default Re: gsm modem with 16f877a

    HI.
    how to get tower infomation modem,anybody help me.
    thank you
    kumara

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

    Default Re: gsm modem with 16f877a

    CHECK:
    portb=%11110000
    HSEROUT ["AT",13]
    HSERIN 5000, ERR, [WAIT("OK")]
    pause 200
    PORTb=%00000000
    HIGH PORTB.4
    PAUSE 15000
    HSEROUT ["at+cmgs=",34,"07xxxxxxxxx",34,13]
    PAUSE 100
    HSEROUT ["SYSTEM OK",26]
    HSERIN 5000, ERR, [WAIT("OK")]
    HSEROUT ["at+cmgs=",34,"0719099795",34,13]
    PAUSE 100
    HSEROUT ["SYSTEM OK",26]
    HSERIN 5000, ERR, [WAIT("OK")]
    low portb.4

    'get initial status
    PortDStatus.0 = PORTD.0
    PortDStatus.1 = PORTD.1
    PortDStatus.2 = PORTD.2
    BEGIN:
    HIGH PORTB.7
    PAUSE 200
    LOW PORTB.7
    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
    if PORTD.2 != PortDStatus.2 then 'sensed change in PORTD.1
    pause 10
    PortDStatus.2 = PORTD.2 'save new status for PORTD.1
    IF PORTD.2 = 1 then
    gosub SEND_SMS4
    else 'PORTD.1 = 0
    gosub SEND_SMS5
    endif
    endif
    PAUSE 10

  14. #14
    Hero000's Avatar
    Hero000 Guest

    Default Re: gsm modem with 16f877a

    Quote Originally Posted by kumara View Post
    my sms project
    Attachment 6608
    3 input and 3 out put
    kumara"" I'm highly interested about it, please tell me about its working formula, efficiency etc.

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