Pic18F4550 + SIMCOM SIM900D GSM/GPRS


Closed Thread
Results 1 to 39 of 39

Hybrid View

  1. #1
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924

    Default Re: Pic18F4550 + SIMCOM SIM900D GSM/GPRS( a little sign of progress)

    I do not see anyplace in the code in post#3 to call GSM_CHECK_ERR
    And your last post has GOTO main commented out falling through to END.

    Maybe with all of the trouble shooting there are other typos? Sorry that I can not spot the problem directly.
    Dave
    Always wear safety glasses while programming.

  2. #2
    Join Date
    Sep 2009
    Posts
    748

    Default Re: Pic18F4550 + SIMCOM SIM900D GSM/GPRS( a little sign of progress)

    Try
    HSERIN [WAIT("CSQ: "),DEC Signal]
    SEROUT2 ....[DEC Signal]
    You don't have 13 chars, after AT+CSQ:...
    From manual
    STR ArrayVar\n{\c} Receive string of n characters optionally ended in character c
    So If you want to string end after receiving CRLF
    Try this
    Serialdata var byte[4]
    HSERIN 4000, GSM_CHECK, [WAIT("AT+CSQ"),STR Serialdata\4\13]

  3. #3
    Join Date
    Jun 2011
    Location
    Philippines
    Posts
    223

    Default Re: Pic18F4550 + SIMCOM SIM900D GSM/GPRS( a little sign of progress)

    @pedja089
    Thanks for the time helping..I tried the to call the following code below.
    Code:
    GSM_SIGCHECK:
    High PORTB.0     ' 1st LED on
    PAUSE 1000
    low PORTB.0
    PAUSE 1000
    HSEROUT ["AT+CSQ",13]                    'Send AT to modem followed by a CR
    HSERIN 4000, GSM_CHECK_ERR, [WAIT("CSQ: "),DEC Signal]
    SEROUT2 PORTD.5, 84,[$D,DEC Signal]
    DEC Signal displays 14 which is I know it is correct. But when I try to call this block of code(pressing the 3rd button) 2nd time it calls GSM_CHECK_ERR...instead of 14. Works again if I press the RESET button.
    What do you think it is causing this issue?

    regards,
    tacbanon
    Last edited by tacbanon; - 14th July 2012 at 14:23.

  4. #4
    Join Date
    Jun 2011
    Location
    Philippines
    Posts
    223

    Default Re: Pic18F4550 + SIMCOM SIM900D GSM/GPRS( a little sign of progress)

    Quote Originally Posted by mackrackit View Post
    I do not see anyplace in the code in post#3 to call GSM_CHECK_ERR
    And your last post has GOTO main commented out falling through to END.

    Maybe with all of the trouble shooting there are other typos? Sorry that I can not spot the problem directly.
    Sorry about that mackrackit...yeah I'm kinda dizzy now (been working on this since last night) below is the code what I was using.
    Code:
     asm
        __CONFIG    _CONFIG1L, _PLLDIV_5_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_2_1L
        __CONFIG    _CONFIG1H, _FOSC_HSPLL_HS_1H & _FCMEN_OFF_1H & _IESO_OFF_1H
        __CONFIG    _CONFIG2L, _PWRT_ON_2L & _BOR_ON_2L  & _BORV_2_2L  & _VREGEN_ON_2L   
        __CONFIG    _CONFIG2H, _WDT_OFF_2H 
        __CONFIG    _CONFIG3H, _MCLRE_ON_3H & _LPT1OSC_OFF_3H & _PBADEN_OFF_3H & _CCP2MX_ON_3H 
        __CONFIG    _CONFIG4L, _STVREN_ON_4L & _LVP_OFF_4L & _ICPRT_OFF_4L  & _XINST_OFF_4L & _DEBUG_OFF_4L 
    endasm
    
            
            DEFINE OSC 48
      
    
            DEFINE HSER_RCSTA 90h ' enable serial port, 
            DEFINE HSER_TXSTA 20h  ' enable transmit, * we change 20h to 36 for 115200          
            DEFINE HSER_BAUD 9600
            DEFINE HSER_CLOERR  1 ' automatic clear overrun error  
            
            TRISC  = %10000000    ' PORTC.7 is the RX input, PORTC.6 is the TX output
                                  
        
        '   Serial communication definition
        '   ===============================
            '
    ADCON1 = %00001111      'Set up ADCON1 register no matter what you're doing!!!!!!
    '::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    
    INCLUDE "MODEDEFS.BAS"       ' Include Shiftin/out modes
    
    
    '*****************************************************************************     
    
    Serialdata var    byte[13]
    INTCON2.7 = 0        ' Enable PORTB pull-ups
    
    TRISB = %11111000
    TRISC = %10000000
    led1 var PortC.0
    cntr var byte
    cntr = 0
    TRISD = %00000000
    
     
    Serout2 PORTD.5, 84, [$1B,$63,$30]
    gosub CLR_SCRN
    
     
    main:
    PORTB = 0            ' PORTB lines low to read buttons
    TRISB = %11111000 
    
       If PORTB.6 = 0 Then ' If 3rd button pressed...
          PORTB.2 = 1      ' 3rd LED on
          gosub CLR_SCRN
          Serout2 PORTD.5, 84, [$D, "Button 3 "]
          pause 500
          gosub CLR_SCRN
          GOSUB GSM_SIGCHECK
          Endif
          
       If PORTB.5 = 0 Then ' If 2nd button pressed...
          PORTD.1 = 1      ' 2nd LED on
         gosub CLR_SCRN
          Serout2 PORTD.5, 84, [$D, "Button 2 "]
          pause 500
          gosub CLR_SCRN
          gosub GSM_MODEL 
       Endif
    
       pause 260   ' pause to avoid sending repetation
    
    
     goto main
    End   'End program
    
    GSM_SIGCHECK:
    High PORTB.0     ' 1st LED on
    PAUSE 1000
    low PORTB.0
    PAUSE 1000
    HSEROUT ["AT+CSQ",13]                    'Send AT to modem followed by a CR
    HSERIN 4000, GSM_CHECK_ERR, [WAIT("AT+CSQ"),STR Serialdata\13]
    Serout2 PORTD.5, 84, [$D, STR Serialdata\13]
    RETURN
    
    GSM_CHECK_ERR:
    Serout2 PORTD.5, 84, [$D, "GSM ERROR"]  
    
    Return
     
    GSM_MODEL:
    High PORTB.0     ' 1st LED on
    PAUSE 1000
    low PORTB.0
    PAUSE 1000
    HSEROUT ["AT+CGMI",13]                           'Ask model name
    HSERIN 4000, GSM_CHECK_ERR, [WAIT("AT+CGMI"),STR Serialdata\13]   'Check model name  "SIMCOM_Ltd"
    Serout2 PORTD.5, 84, [$D, STR Serialdata\13]
    return
    
    CLR_SCRN:
    cntr=cntr+1
    Serout2 PORTD.5, 84, [$1B,$45,"GSM DEBUG PORT ",#cntr]
    return
    Thanks in advance,
    tacbanon
    Last edited by tacbanon; - 14th July 2012 at 15:01.

  5. #5
    Join Date
    Jun 2011
    Location
    Philippines
    Posts
    223

    Default Re: Pic18F4550 + SIMCOM SIM900D GSM/GPRS( a little sign of progress)

    Oops I also forgot to mention that I'm using 9600 baud rate, I thought it will change anything...

  6. #6
    Join Date
    Sep 2009
    Posts
    748

    Default Re: Pic18F4550 + SIMCOM SIM900D GSM/GPRS( a little sign of progress)

    Check does it send correctly with HT. Use your usb ttl uart converter board.
    Try to send CRLF then pause 100, and then send command...

  7. #7
    Join Date
    Jun 2011
    Location
    Philippines
    Posts
    223

    Default Re: Pic18F4550 + SIMCOM SIM900D GSM/GPRS( a little sign of progress)

    Quote Originally Posted by pedja089 View Post
    Check does it send correctly with HT. Use your usb ttl uart converter board.
    Try to send CRLF then pause 100, and then send command...
    On the SERIAL COMMUNICATORl, sending AT commands had no problems( w/ CR and CRLF).
    Name:  CRLF.png
Views: 11917
Size:  65.6 KB

    Regards,
    tacbanon

  8. #8
    Join Date
    Jun 2011
    Location
    Philippines
    Posts
    223

    Default Re: Pic18F4550 + SIMCOM SIM900D GSM/GPRS( a little sign of progress)

    I tried other serial communicator, and I'm not sure if I found the trouble...
    Name:  WithNewLine.png
Views: 11929
Size:  46.5 KB
    When I disable the Append New Line

    Name:  WithNewLine2.png
Views: 12010
Size:  47.5 KB
    With New line after sending

    Do you think adding new line after each send will solve it - how?

    Code:
    HSEROUT ["AT",13] 
    HSERIN 4000, GSM_CHECK_ERR, [WAIT("OK")]
    The code above does not detect "OK".

    regards,
    tacbanon

  9. #9
    Join Date
    Sep 2009
    Posts
    748

    Default Re: Pic18F4550 + SIMCOM SIM900D GSM/GPRS( a little sign of progress)

    Try to connect PC to PIC, instead of modem...
    Also use Rx on PC board to sniff what is happening when pic and modem communicate...

Members who have read this thread : 0

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