[SOLVED] GSM MOD9001 is not responding to PIC18F4550

Status
Not open for further replies.

Mithun_K_Das

Advanced Member level 3
Joined
Apr 24, 2010
Messages
899
Helped
24
Reputation
48
Reaction score
26
Trophy points
1,318
Location
Dhaka, Bangladesh, Bangladesh
Visit site
Activity points
8,254
HI, I was working with GSM module "MOD9001". I tried with PC and my PIC board. The modem is working very fine with my PC at BR:115200; also the circuit I designed is working good with PC @ BR115200; But the modem is not working with circuit.

I can't find the fault here. Can you help me?
here is the code I'm trying...

Code:
/******************************************************************************
Program for VTS_with_GSM
Program written by Engr. Mithun K. Das
Email: mithun060@gmail.com
MCU: PIC16F877A; X_Tal: 8MHz(external)
Date: 23/11/2013;
******************************************************************************/
// LCD module connections
sbit LCD_RS at RB7_bit;
sbit LCD_EN at RB6_bit;
sbit LCD_D4 at RB5_bit;
sbit LCD_D5 at RB4_bit;
sbit LCD_D6 at RB3_bit;
sbit LCD_D7 at RB2_bit;

sbit LCD_RS_Direction at TRISB7_bit;
sbit LCD_EN_Direction at TRISB6_bit;
sbit LCD_D4_Direction at TRISB5_bit;
sbit LCD_D5_Direction at TRISB4_bit;
sbit LCD_D6_Direction at TRISB3_bit;
sbit LCD_D7_Direction at TRISB2_bit;
// End LCD module connections

unsigned char uart_rd;     // read the received data,

void UART()
{

    uart1_write_text("AT");
    UART1_Write(13);
    UART1_Write(10);
    delay_ms(100);
    uart_rd = UART1_Read();     // read the received data,
    Lcd_Out(2,1,uart_rd);// and send data via UART
    //uart1_write_text("AT+CMGF=1");
    uart1_write_text("ATD01722448270;");
    UART1_Write(13);
    UART1_Write(10);
    delay_ms(20000);

    uart1_write_text("AT+CMGF=1");
    UART1_Write(13);
    UART1_Write(10);
    delay_ms(5000);

    UART1_Write_text("AT+CMGS=\"01722448270\"");
    UART1_Write(13);
    UART1_Write(10);
    delay_ms(5000);

    UART1_Write_Text("Testing123");
    UART1_Write(0x1A);// enter Ctrl+Z
    UART1_Write(13);
    UART1_Write(10);
    delay_ms(5000);
}

void main() 
{



  Lcd_Init();                        // Initialize LCD
  Lcd_Cmd(_LCD_CLEAR);               // Clear display
  Lcd_Cmd(_LCD_CURSOR_OFF);          // Cursor off

  Delay_ms(1000);
  
  
  uart1_init(115200);

  delay_ms(5000);
  
  while(1)
  {
     Lcd_Cmd(_LCD_CLEAR);
     Lcd_Out(1,1,"AT");
     Delay_ms(1000);
     UART();            //Call function
     Delay_ms(3000);
     Lcd_Cmd(_LCD_CLEAR);
  }//while
}//void
 


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
unsigned uart_rd[20] = "";
 
void UART(){
 
    unsigned char i = 0;
sendAT:
    UART1_Write_Text("AT\r\n");
    
    while((uart_rd[0] != '>') && (uart_rd[1] != 'O') && (uart_rd[2] != 'K')){
        uart_rd[i] = UART1_Read();
        i++;
        if((i == 3) && ((uart_rd[0] != '>') && (uart_rd[1] != 'O') && (uart_rd[2] != 'K'))
            goto sendAT;
    }
    
    uart_rd[3] = '\0';
 
     
    Lcd_Out(2,1,uart_rd);
    UART1_Write_Text("AT+CMGF=1\r\n");
    Delay_ms(1000);
    UART1_Write_Text("ATD01722448270;\r\n");
    Delay_ms(5000);
 
    UART1_Write_Text("AT+CMGF=1\r\n");
    Delay_ms(2000);
 
    UART1_Write_Text("AT+CMGS=\"01722448270\"\r\n");
    Delay_ms(5000);
 
    UART1_Write_Text("Testing123");
    Delay_ms(100);
    UART1_Write(0x1A);
    UART1_Write(13);
    UART1_Write(10);
    Delay_ms(5000);
}




 
Last edited:



I can't find the error. can you?

- - - Updated - - -

Solved that problem replacing unsigned

Code:
uart_rd[20]=""; by unsigned char uart_rd[20]="";
but still the modem is not responding.

- - - Updated - - -

Is there any problem with BOUD RATE? The circuit is working very fine with PC. But only can't with the modem. I checked all the data connections; they seems like ok. Also the modem is working fine with PC.
 

File attached. I have used 9600 bps baudrate as Proteus was giving wrong data for higher baudrate. Simulation video inside .rar file. Pull down uC Rx and Tx lines. There is a strange behaviour. I don't know why "OK" is not displayed on LCD.
 

Attachments

  • GSM Test.rar
    117.4 KB · Views: 94

Yes! the whole system works fine at BR:9600. But MOD9001 doesn't support BR:9600. Only 115200 is supported as far I know according to its datasheet. I don't know how can I fix this problem.
 

Connect uC to PC using MAX232. If needed you can use RS232 to USB adapter between MAX232 and PC if you don't have COM port. Install RealTerm and set to 115200N1 and make uC send some data every 1 sec. See if you get right data at PC. If yes, then uC is sending right data else uC baudrate is not correct.
 

Yes! I connected my circuit with PC via RS232 (includes MAX232 in between); At BR: 115200, the MCU is sending data, PC showing it ok.
AT
AT+... etc. everything is ok.

On the other hand, I connected MOD9001 with that same RS232 with PC, its also ok.

One important thing I've found that, the MCU is not receiving the right data. If I write OK at the PC hyperterminal, MCU is showing funny characters.


It may be a clue of the fault I'm having here.
 



I checked the modem and circuit. The circuit sends data to PC and also the modem is responding, But if I connect both modem and circuit with PC, it shows this.

- - - Updated - - -



connection between PC and Modem[MOD9001]

- - - Updated - - -

Yes! Finally its working. Here is the code what is working finally: also previous circuit diagram with RS232 is maintained.
Code:
/******************************************************************************
Program for VTS_with_GSM
Program written by Engr. Mithun K. Das
Email: mithun060@gmail.com
MCU: PIC18F4550A; X_Tal: 20MHz(external)
Date: 23/11/2013;
******************************************************************************/
// LCD module connections
sbit LCD_RS at RB7_bit;
sbit LCD_EN at RB6_bit;
sbit LCD_D4 at RB5_bit;
sbit LCD_D5 at RB4_bit;
sbit LCD_D6 at RB3_bit;
sbit LCD_D7 at RB2_bit;

sbit LCD_RS_Direction at TRISB7_bit;
sbit LCD_EN_Direction at TRISB6_bit;
sbit LCD_D4_Direction at TRISB5_bit;
sbit LCD_D5_Direction at TRISB4_bit;
sbit LCD_D6_Direction at TRISB3_bit;
sbit LCD_D7_Direction at TRISB2_bit;
// End LCD module connections

unsigned char uart_rd=0;

void Send_ATcmd() 
{ 
   UART1_Write((char)13); //try it using comment and uncomment this line
   UART1_Write((char)10);
   
   UART1_Write((char)'A');
   UART1_Write((char)'T');
   UART1_Write((char)13); //try it using comment and uncomment this line
   UART1_Write((char)10);
 }

void Send_AT_CMGF()
{
   UART1_Write((char)'A');
   UART1_Write((char)'T');
   UART1_Write((char)'+');
   UART1_Write((char)'C');
   UART1_Write((char)'M');
   UART1_Write((char)'G');
   UART1_Write((char)'F');
   UART1_Write((char)'=');
   UART1_Write((char)'1');
   UART1_Write((char)13); //try it using comment and uncomment this line
   UART1_Write((char)10);
 }
 
 void Send_AT_CMGS()
{
   UART1_Write((char)'A');
   UART1_Write((char)'T');
   UART1_Write((char)'+');
   UART1_Write((char)'C');
   UART1_Write((char)'M');
   UART1_Write((char)'G');
   UART1_Write((char)'S');
   UART1_Write((char)'=');
   UART1_Write((char)'"');
   UART1_Write((char)'0');
   UART1_Write((char)'1');
   UART1_Write((char)'7');
   UART1_Write((char)'2');
   UART1_Write((char)'2');
   UART1_Write((char)'4');
   UART1_Write((char)'4');
   UART1_Write((char)'8');
   UART1_Write((char)'2');
   UART1_Write((char)'7');
   UART1_Write((char)'0');
   UART1_Write((char)'"');
   UART1_Write((char)13); //try it using comment and uncomment this line
   UART1_Write((char)10);
 }
 
 void Send_SMS()
 {
   UART1_Write((char)'T');
   UART1_Write((char)'E');
   UART1_Write((char)'S');
   UART1_Write((char)'T');
   
   UART1_Write(26);// send ctrl + Z
   Delay_ms(2000);
   UART1_Write((char)13); //try it using comment and uncomment this line
   UART1_Write((char)10);
 }

void main() 
{

  TRISC7_bit = 1;
  TRISC6_bit = 0;
  ADCON1 = 0xFF;

  Lcd_Init();                        // Initialize LCD
  Lcd_Cmd(_LCD_CLEAR);               // Clear display
  Lcd_Cmd(_LCD_CURSOR_OFF);          // Cursor off

  Delay_ms(1000);
  
  
  UART1_init(114200);

  delay_ms(3000);

  while(1)
  {
     Lcd_Cmd(_LCD_CLEAR);
     Lcd_Out(1,1,"Sending Data...");
     Delay_ms(2000);
     Send_ATcmd();
       
       uart_rd = UART1_Read();
       Lcd_Out(2,1,uart_rd);
       Delay_ms(500);
       
       Send_AT_CMGF();

       uart_rd = UART1_Read();
       Lcd_Out(2,1,uart_rd);
       
       Delay_ms(500);

       Send_AT_CMGS();

       uart_rd = UART1_Read();
       Lcd_Out(2,1,uart_rd);
       
       Delay_ms(500);
       Send_SMS();
       uart_rd = UART1_Read();
       Lcd_Out(2,1,uart_rd);
       
      Delay_ms(2000);


  }//while
}//void


Also, BR is reduced a little bit.
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…