Remove Text Formatting
Loading...

+ Reply to Thread
Results 1 to 39 of 39
  1. #1
    Join Date
    Jun 2011
    Location
    Philippines
    Posts
    223

    Default Pic18F4550 + SIMCOM SIM900D GSM/GPRS

    Hello to everyone,
    I have a SIMCOM SIM900D GSM/GPRS module. I'm trying to make it communicate with the Pic18F4550 with 20Mhz crystal. But before that I made sure that the module is working/replying to AT commands by connecting it the serial port communicator via USB - TTL converter. And I confirmed that PC(Serial communicator) -> USB-TTL converter + GSM(Baud 115200) module are working.
    Name:  GSM-usbttl.png
Views: 13336
Size:  77.4 KB

    Then the next step I did is to try to send HSEROUT ["AT",13] to the GSM module..using hardware setup below
    Name:  GSM-LABX2.png
Views: 8288
Size:  126.2 KB
    and this is the code I'm 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 36  ' enable transmit, * we change 20h to 36 for 115200          
            DEFINE HSER_BAUD 115200
            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
    
    INTCON2.7 = 0        ' Enable PORTB pull-ups
    TRISB = %11111000
    TRISC = %10000000
    led1 var PortC.0
    TRISD = %00000000
    
     
    Serout2 PORTD.5, 84, [$1B,$63,$30]  'cursor off for serial LCD
    Serout2 PORTD.5, 84, [$1B,$45,"SMS DEBUG PORT"]   ' serial LCD
    main:
    PORTB = 0            ' PORTB lines low to read buttons
    
       If PORTB.4 = 0 Then ' If 1st button pressed...
         
          HSEROUT ["Button 1",13]
          Serout2 PORTD.5, 84, [$1B,$45, "SMS DEBUG PORT"]
          Serout2 PORTD.5, 84, [$D, "Button 1 "]
          pause 500
          Serout2 PORTD.5, 84, [$1B,$45,"SMS DEBUG PORT"]
          gosub GSM_CHECK 
       Endif
       pause 200   ' pause to avoid sending repetation
    
    goto main
    
    End   'End program
    
    
    GSM_CHECK:
    HSEROUT ["AT",13]                    'Send AT to modem followed by a CR
    HSERIN 5000, GSM_CHECK_ERR, [WAIT("OK")] 'Check OK reply, wait 5sec max.
    Serout2 PORTD.5, 84, [$D, "GSM OK"]
    High PORTB.0     ' 1st LED on
    PAUSE 1000
    low PORTB.0
    return
    
     GSM_CHECK_ERR:
     Serout2 PORTD.5, 84, [$D, "GSM ERROR"]   
     
     ;HSEROUT ["GSM_ERROR",13]
     Return
    I tried to interchange C6 and C7 lines but still I'm not getting "OK" response...hope anyone can give a me hint what I'm missing in my setup.

    Thanks in advance,
    tacbanon
    Last edited by tacbanon; - 14th July 2012 at 00:31.

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

    Default Re: Pic18F4550 + SIMCOM SIM900D GSM/GPRS

    A quick guess. You need to invert the signal. Try a max232 in between??
    Dave
    Always wear safety glasses while programming.

  3. #3
    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
    A quick guess. You need to invert the signal. Try a max232 in between??
    Hi mackrackit,
    I did some more testing and the following codes works but still have some issues.
    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 36  ' enable transmit, * we change 20h to 36 for 115200          
            DEFINE HSER_BAUD 115200
            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[25]
    
    INTCON2.7 = 0        ' Enable PORTB pull-ups
    TRISB = %11111000
    TRISC = %10000000
    led1 var PortC.0
    TRISD = %00000000
    
     
    Serout2 PORTD.5, 84, [$1B,$63,$30]
    Serout2 PORTD.5, 84, [$1B,$45,"SMS DEBUG PORT"]
    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
          Serout2 PORTD.5, 84, [$1B,$45, "SMS DEBUG PORT"]
          Serout2 PORTD.5, 84, [$D, "Button 3 "]
          pause 500
          Serout2 PORTD.5, 84, [$1B,$45,"SMS DEBUG PORT"]
          GOSUB GSM_SIGCHECK
          Endif
          
       If PORTB.5 = 0 Then ' If 2nd button pressed...
          PORTD.1 = 1      ' 2nd LED on
          Serout2 PORTD.5, 84, [$1B,$45, "SMS DEBUG PORT"]
          Serout2 PORTD.5, 84, [$D, "Button 2 "]
          pause 500
          Serout2 PORTD.5, 84, [$1B,$45,"SMS DEBUG PORT"]
          gosub GSM_MODEL 
       Endif
    
       pause 240   ' pause to avoid sending repetation
    
    
     goto main
    End   'End program
    
    GSM_SIGCHECK:
    HSEROUT ["AT+CSQ",13]                    'Send AT to modem followed by a CR
    HSERIN 4000, GSM_CHECK, [WAIT("AT+CSQ"),STR Serialdata\13] 'Check OK reply, wait 5sec max.
    Serout2 PORTD.5, 84, [$D, STR Serialdata\13]
    High PORTB.0     ' 1st LED on
    PAUSE 1000
    low PORTB.0
    RETURN
    
    GSM_CHECK_ERR:
    Serout2 PORTD.5, 84, [$D, "GSM ERROR"]   
    Return
     
    GSM_MODEL:
    HSEROUT ["AT+CGMI",13]                           'Ask model name
    HSERIN 4000, GSM_MODEL, [WAIT("AT+CGMI"),STR Serialdata\13]   'Check model name  "SIMCOM_Ltd"
    Serout2 PORTD.5, 84, [$D, STR Serialdata\13]
    High PORTB.0     ' 1st LED on
    PAUSE 1000
    low PORTB.0
    return
    After pressing each button (response displayed to the LCD) I need to press the RESET button of the LABX2 everytime.
    What do you think its causing this?

    Regards,
    tacbanon

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

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

    Again, just guessing..

    Maybe the module is sending something but not what is expected.
    Try moving the LED feed back to the beginning of the routine to see if it is stuck there.
    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, [WAIT("AT+CSQ"),STR Serialdata\13] 'Check OK reply, wait 5sec max.
    Serout2 PORTD.5, 84, [$D, STR Serialdata\13]
    RETURN
    Dave
    Always wear safety glasses while programming.

  5. #5
    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
    Again, just guessing..

    Maybe the module is sending something but not what is expected.
    Try moving the LED feed back to the beginning of the routine to see if it is stuck there.
    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, [WAIT("AT+CSQ"),STR Serialdata\13] 'Check OK reply, wait 5sec max.
    Serout2 PORTD.5, 84, [$D, STR Serialdata\13]
    RETURN
    Hi macrackit,
    Thanks for helping me out...but I still have the same issue. It works only once and needs to hit the RESET button in order to read incoming value.

    Regards,
    tacbanon

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

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

    How far does it get before it locks up exactly?
    Is it receiving the AT+CSQ ?
    Dave
    Always wear safety glasses while programming.

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

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

    It locks up just right after it performs the first AT command..the same result when I rearrange the code.
    Code:
    main:
    PORTB = 0            ' PORTB lines low to read buttons
    TRISB = %11111000 
    ;gosub CLR_SCRN
    GOSUB GSM_SIGCHECK
    ;gosub CLR_SCRN
    gosub GSM_MODEL 
    
    pause 260   ' pause to avoid sending repetition
    
    ;goto main
    End   'End program
    it perform GOSUB GSM_SIGCHECK then after it it never performs the gosub GSM_MODEL correctly and calls GSM_CHECK_ERR:
    I also tried to interchange the sequence but the same results. It performs the GOSUB GSM_MODEL but failed to execute GOSUB GSM_SIGCHECK correctly.

    /tacbanon
    Last edited by tacbanon; - 14th July 2012 at 12:21.

  8. #8
    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.

  9. #9
    Join Date
    Sep 2009
    Posts
    609

    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]

  10. #10
    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.

  11. #11
    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.

  12. #12
    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...

  13. #13
    Join Date
    Sep 2009
    Posts
    609

    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...

  14. #14
    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: 7507
Size:  65.6 KB

    Regards,
    tacbanon

  15. #15
    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: 7556
Size:  46.5 KB
    When I disable the Append New Line

    Name:  WithNewLine2.png
Views: 7698
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

  16. #16
    Join Date
    Sep 2009
    Posts
    609

    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...

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

    Default Troubleshooting...

    I tried to modify my hardware setup to detect whats going IN and OUT in the GSM module (below). I test each button(Button1-Button3) and each corresponding response of the GSM shown in the serial communicator.
    Name:  pic_gsm_pc_view.png
Views: 8352
Size:  40.6 KB

    I noticed that everything seems normal..but when I tried the connection PIC-GSM... I have the same issue.
    So sending PIC to GSM AT commands is not issue..I think when receiving incoming data from GSM to PIC is where the trouble is.

    Regards,
    tacbanon

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

    Default Re: Troubleshooting...

    I noticed that everything seems normal..but when I tried the connection PIC-GSM... I have the same issue.
    What I meant was, when I set the entire connection between PIC-GSM I have the trouble again(need to press the reset button on my Labx2 devboard)

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

    Default Re: Troubleshooting...

    For testing I removed all HSERIN command to see if it will continue each line. And below is the results.
    Name:  anothertest.png
Views: 7443
Size:  32.1 KB
    Here is the code I'm 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
    
    
    '*****************************************************************************     
    
    
    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]  
    Serout2 PORTD.5, 84, [$1B,$45, "Start GSM SIMU"]   ' Serial LCD
    main:
    
    PAUSE 1000
    HSEROUT ["AT",13,10]                    'Send AT to modem followed by a CR
    pause 200
    cntr=cntr+1
    Serout2 PORTD.5, 84, [$1B,$45,"Start GSM SIMU"]
    Serout2 PORTD.5, 84, [$D,"AT -Done",#cntr]
    cntr=cntr+1
    
    pause 1000
    HSEROUT["AT+CMGF=1",13]             'Here the GSM module is being entered in TEXT MODE.
    PAUSE 1000
    HSEROUT ["AT+CSQ",13,10]                    
    pause 200
    Serout2 PORTD.5, 84, [$1B,$45,"Start GSM SIMU"]
    Serout2 PORTD.5, 84, [$D, "SIGNAL CHK",#cntr]
    
    
    PAUSE 1000
    HSEROUT ["AT+CGMI",13,10]                           'Ask model name
    pause 200
    cntr=cntr+1
    Serout2 PORTD.5, 84, [$1B,$45,"Start GSM SIMU"]
    Serout2 PORTD.5, 84, [$D, "MANUFACT CHK",#cntr]
    
    Pause 1000
    Serout2 PORTD.5, 84, [$1B,$45,"Start GSM SIMU"]
    Serout2 PORTD.5, 84, [$D,"GSM TEST DONE!",#cntr]
    
    End     ' End of program
    Can anyone pin point what I'm doing wrong in my code..and why HSERIN is not detecting data coming out from GSM?
    I Appreciate any help.

    Thanks in advance,
    tacbanon

  20. #20
    Join Date
    Sep 2009
    Posts
    609

    Default Re: Troubleshooting...

    Maybe problem is in supply voltage. Modem works on 2.8V(it have internal regulator), so pic should work on 3.3V, and you must have serial resistor on pic TX. So modem can't draw any current from pic TX pin.

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

    Default Re: Troubleshooting...

    Quote Originally Posted by pedja089 View Post
    Maybe problem is in supply voltage. Modem works on 2.8V(it have internal regulator), so pic should work on 3.3V, and you must have serial resistor on pic TX. So modem can't draw any current from pic TX pin.
    Probably that is the case I'm having trouble with...serial resistor? Like a voltage divider?
    Here is the general Specification of the GSM
    Power Input:
    5V-7.5VDC @ 1.5A

    I/O Interface:
    UART 3.3V Logic 5V Tolerant

    Regards,
    tacbanon

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

    Default Re: Troubleshooting...

    I still think you may need to use a max232 between the PIC and the device as you have mentioned the device works when connected directly to a PC.
    Dave
    Always wear safety glasses while programming.

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

    Default Re: Pic18F4550 + SIMCOM SIM900D GSM/GPRS

    I still think you may need to use a max232 between the PIC and the device as you have mentioned the device works when connected directly to a PC.
    if that is the case,

    You can invert the comms for the pic18f4550. This will make it possible to talk to a modem without a rs232 chip: http://www.picbasic.co.uk/forum/showthread.php?t=10361
    Last edited by ScaleRobotics; - 15th July 2012 at 15:13.
    http://www.scalerobotics.com

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

    Default Re: Pic18F4550 + SIMCOM SIM900D GSM/GPRS

    Quote Originally Posted by ScaleRobotics View Post
    if that is the case,

    You can invert the comms for the pic18f4550. This will make it possible to talk to a modem without a rs232 chip: http://www.picbasic.co.uk/forum/showthread.php?t=10361
    I found it on page 240(datasheet) BAUDCON: BAUD Rate Control Register
    Bit 4
    1 = TX data is inverted
    Bit 5
    1 = RX data is inverted
    Please correct me if I'm doing it wrong...
    Baudcon.4 = 1
    Baudcon.5 = 1

    regards,
    tacbanon

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

    Default Re: Pic18F4550 + SIMCOM SIM900D GSM/GPRS

    That is correct. And make sure your voltages match, so no one gets hurt.
    http://www.scalerobotics.com

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

    Default Re: Pic18F4550 + SIMCOM SIM900D GSM/GPRS

    Quote Originally Posted by ScaleRobotics View Post
    And make sure your voltages match, so no one gets hurt.
    Sorry to ask this...but to make sure. GSM module I/O Interface UART 3.3V Logic 5V Tolerant, connecting to my LABX2 I think is safe even with the modification of BAUDCON...am right?

    thanks for the help,
    tacbanon

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

    Default Re: Pic18F4550 + SIMCOM SIM900D GSM/GPRS

    Are you using some kind of shield, or the SIM900D development board? Can you point me to a schematic for the one you have? If shield, did you connect some kind of rs-232 to connect it to your computer?
    Last edited by ScaleRobotics; - 16th July 2012 at 18:51.
    http://www.scalerobotics.com

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

    Default Re: Pic18F4550 + SIMCOM SIM900D GSM/GPRS

    Hi ScaleRobotics,
    Yes I'm using a shield..sorry I can not seem to find the schematic. I used USB -to TTL module to communicate with the PC.
    Name:  Gsmshield.png
Views: 7505
Size:  393.6 KB

    /tacbanon

  29. #29
    Join Date
    Sep 2009
    Posts
    609

    Default Re: Pic18F4550 + SIMCOM SIM900D GSM/GPRS

    Usb-TTL serial module use true 3.3V uart.
    You port setup was ok, because you menage to get signal from modem, to pic, and send it to pc from pic...
    Also TX from pic is ok, because you get result(post 17) on PC when you connect USB module to modem tx...
    So check your ground, and check pic input type, maybe 2.8V isn't enough to ensure logic 1.

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

    Default Re: Pic18F4550 + SIMCOM SIM900D GSM/GPRS

    @pedja089
    I checked the grounding..but still no changes.
    Sorry for being a noob, but I tried to get the voltage from GSM Tx(4.2v) Rx(4.9v). I also tried to use max232..and still no positive results...I'm totally lost

    /tacbanon

  31. #31
    Join Date
    Sep 2009
    Posts
    609

    Default Re: Pic18F4550 + SIMCOM SIM900D GSM/GPRS

    I'm have board with sim900 connected to pic. Modem have 4V supply, pic have 3.3V.
    SIM900 use TTL 2.8V true uart, not inverted. I put just 2 resistor in series with comm lines.
    If you connect modem to rs232 side of max232, probably you frayed modem port.
    1. Connect modem and usb board, and check that.
    2. I tell you to try to connect your usb board to PIC instead of modem board. So you can check that communication is ok on PIC side...
    You didn't try that...
    So try to send response from PC to PIC. Only in HSERIN put longer timeout, eg 5s..
    3.You said in post 10 you menage to get signal level. So your hardware setup was ok.

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

    Default Re: Pic18F4550 + SIMCOM SIM900D GSM/GPRS

    @pedja089
    Hi sorry took me so long to reply...in post #10 I was able to get the signal level only once(upon power on)...I have to reset my LabX2 to get the reading again. I will try to get another GSM module probably by next week to see if the result is the same...and post here the output. Thanks all for the help and more power to PBP forum!

    Regards,
    tacbanon

  33. #33
    Join Date
    Sep 2009
    Posts
    609

    Default Re: Pic18F4550 + SIMCOM SIM900D GSM/GPRS

    If you get once reply from modem, your hardware was ok.
    Is anything was wrong you won't get reply if you restart or not...

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

    Default Re: Pic18F4550 + SIMCOM SIM900D GSM/GPRS

    Hi tacbanon,

    I loaded your code from post 19 into a circuit here, and tested hserout with your settings. I couldn't seem to get anything out, unless I removed your brown out reset in the configs.

    If you change this line, does it help anything?

    ; __CONFIG _CONFIG2L, _PWRT_ON_2L & _BOR_ON_2L & _BORV_2_2L & _VREGEN_ON_2L
    __CONFIG _CONFIG2L, _PWRT_ON_2L & _BOR_OFF_2L & _VREGEN_ON_2L

    As a side note, for 115200 baud on earlier code, I had to use:
    'DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive
    'DEFINE HSER_TXSTA 20h ' Enable transmit, BRGH = 0
    'DEFINE HSER_CLROERR 1 ' Clear overflow automatically
    'DEFINE HSER_SPBRG 25 ' 115200 Baud @ 48MHz, 0.16%
    http://www.scalerobotics.com

  35. #35
    Join Date
    Sep 2009
    Posts
    609

    Default Re: Pic18F4550 + SIMCOM SIM900D GSM/GPRS

    Modem can draw up to 2A. So if you supply pic and modem from same power supply maybe voltage drops and lock your pic.

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

    Default Re: Pic18F4550 + SIMCOM SIM900D GSM/GPRS

    Quote Originally Posted by ScaleRobotics View Post
    Hi tacbanon,

    I loaded your code from post 19 into a circuit here, and tested hserout with your settings. I couldn't seem to get anything out, unless I removed your brown out reset in the configs.

    If you change this line, does it help anything?

    ; __CONFIG _CONFIG2L, _PWRT_ON_2L & _BOR_ON_2L & _BORV_2_2L & _VREGEN_ON_2L
    __CONFIG _CONFIG2L, _PWRT_ON_2L & _BOR_OFF_2L & _VREGEN_ON_2L

    As a side note, for 115200 baud on earlier code, I had to use:
    'DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive
    'DEFINE HSER_TXSTA 20h ' Enable transmit, BRGH = 0
    'DEFINE HSER_CLROERR 1 ' Clear overflow automatically
    'DEFINE HSER_SPBRG 25 ' 115200 Baud @ 48MHz, 0.16%
    Hello ScaleRobotics, That did it...yipee!
    Thanks to you and thanks to everyone in the forum..

    Regards,
    tacbanon

  37. #37
    ghulamqadir90's Avatar
    ghulamqadir90 Guest

    Default Re: Pic18F4550 + SIMCOM SIM900D GSM/GPRS

    any one plz send C source code of above

  38. #38
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,811

    Default Re: Pic18F4550 + SIMCOM SIM900D GSM/GPRS

    Quote Originally Posted by ghulamqadir90 View Post
    any one plz send C source code of above
    This is NOT a "C" forum, it is as it's name implies a PIC BASIC Forum.
    Last edited by Archangel; - 20th May 2015 at 22:43.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  39. #39
    Join Date
    Jul 2016
    Posts
    1

    Default Re: Pic18F4550 + SIMCOM SIM900D GSM/GPRS

    PLZ send the source code of PIC BASIC
    • PIC BASIC


    • PIC BASIC


    BASIC

Members who have read this thread : 7

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