Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

AT Comands from ATmega32 to SIM900 to send SMS

Status
Not open for further replies.
drtvskuthsav said:
Both my modem board and The controller board is having DB9 Female pins. So I thought of using DB9 Male pin - Male Pin Connector. But I checked how the pins of this connector are connected internally. When I tested with multimeter I found that Tx pin of one end of connector is connected to Tx at other end and Simlarly Rx-Rx connections. I think this should not be like this. Am I right? Could this be the problem?
You mean that modem's Tx pin goes to AVR's Tx pin and Rx goes to Rx? Then you are right, it should not be like this. You must use a cross cable that sends pin 2 signal of one side to other's side pin 3 signal and vice versa. There is no way to communicate like you described. Have you tested with the multimeter the connection between modem and PC when you connect it with the PC? Are you using the same cable in both situations?
 

You mean that modem's Tx pin goes to AVR's Tx pin and Rx goes to Rx? Then you are right, it should not be like this. You must use a cross cable that sends pin 2 signal of one side to other's side pin 3 signal and vice versa. There is no way to communicate like you described. Have you tested with the multimeter the connection between modem and PC when you connect it with the PC? Are you using the same cable in both situations?
No alexxx not the same cable. To connect PC and Modem am using 'Female pin to male pin connector' and am using the 'Female pin to male pin connector' if I want to check how my Controller Board when used with pc. My controller board and Modem board both are having Femal Pin DB9. So I bought a Male Pin Male Pin connector. So now I should check for the cross connection between them. I'll try it today and let you know if it worked.
 

Hey Alexxx, it did not help me. Now what to do?? I don't have much time for this. Am working on this for more than a two weeks. Please refer to other board members and help me out.
 

drtvskuthsav said:
Hey Alexxx, it did not help me. Now what to do??
In times when everything seems to fail, someone must use tools for debugging purpose. Osciloscope for hardware, debugger for software. Double check the board's configuration (like jumpers or dip switches). Then start with the osciloscope first. Go to the ATmega Tx pin. Are the serial bytes leaving this pin? Then measure modem's Rx pin. Are those bytes reaching this pin? Then modem's Tx pin and MCU's Rx pin. Follow the signal's path. In this way you will realize where the problem lies. Then you will know where to search in the program as well. If a debugger is available, it will make your life much easier. As I said the UART code seems to be OK. Maybe I missed something who knows? (even though docklight says that bytes are transmitted correctly). It happens sometimes to have a software issue, but without oscilloscope you will not know where to search for bugs in the code. You could do some measurements, share the results and then we can focus on the core of the problem, until now we are blindly searching to all of the code.


drtvskuthsav said:
Please refer to other board members and help me out.
There must be other members following this thread as well, if someone can help I'm sure he will. I cannot ask from other members to contribute to this or any other thread. They have the free will to do so if they want to.
 

Hi, Guys,

Just noted the whole issue with SIM900, is the problem solved, I am reading thru the 24 post, alot of work done.

We been using SIM900D for the past 24-month, our recent order of 200-unit, Feb-2012 order was tool problem, it looks like SIMCOM changed the hardware and had firmware issue too, they give us version B10 (orginally supplied with B08, then upgrade to B09, which solve most of the stability issue, but still facing some problems.

Among the problem we faced was CPIN: NOT INSERTED, even though its inserted and this is reported randomly after XX-Min, alot of other issue, Like bogus NORMAL POWER DOWN.

We stoped using this batch and return the unsolder 180 unit to supplier (the soldered 20-unit they refused to give warranty claim, :evil::evil:), they replaced with SIM900A which worked without any problem.

I am not saying this is the solution to original post, I just shooting my experiences and 2-cent worth.

If need be, lets start FRESH, original POSTER, shot the Current Problem, Let me try my luck.

M.Pathma
 
  • Like
Reactions: alexxx

    alexxx

    Points: 2
    Helpful Answer Positive Rating
mpathma said:
I am not saying this is the solution to original post, I just shooting my experiences and 2-cent worth.
I don't think that this would be the solution, because drtvskuthsav has a problem that the modem responds to the PC, but does not respond to the exact same frames when communicating with the MCU.
But this information is really valuable, many members will get help if they read those lines. Since SIMCOM replaced those parts, it means that there is in deed some kind of a problem with this version.
 

Hi,

If the modem respond when connected to PC and not when connecting to MCU, then check out the following;

Only valid if connection via PC is using all the Rs-232 signals.

When the other Rs-232 is not handle correctly, modem will not reply to MCU which is connected with Rx/Tx only, HyperTerminal will handle flow control automatically.

Normally for MCU connection, I will not handle flow control, I need to check my schematic for the other 232 pin connections. (modem side)

Also, I think there is flow control command, check it out

And PLEASE fix the baud rate using AT+IPR command, SIM900 known for miss respond when using Auto-Baud.

If all fail, please check the Baud Rate Error which MCU generating, remember Hyperterminal have wide error handling, seen cases upto 20% baud rate error Hyperterminal can handle and decode, where as SIM900 or other MCU will fail.

You should check baud rate using scope, do not trust too much on complier advice, I experience PIC24FJ, indicated 2% error (MPLAB-8.3), for 115K, when measures it was 14% and SIM refuse to talk to MCU.

Hope this help.

M.Pathma
 

When the other Rs-232 is not handle correctly, modem will not reply to MCU which is connected with Rx/Tx only, HyperTerminal will handle flow control automatically.

Normally for MCU connection, I will not handle flow control, I need to check my schematic for the other 232 pin connections. (modem side)

Also, I think there is flow control command, check it out
Yes I missed this. I'll check it. I checked the SIM900 Module schematic and found that they used CTS and RTS. I'll attach the file/usermanual of SIM900 module. Please check and let me know What Changes I should do.

And PLEASE fix the baud rate using AT+IPR command, SIM900 known for miss respond when using Auto-Baud.
I fixed the baudrate at 9600 using AT+IPR and AT&W commands when connected with Hyper terminal on PC.

If all fail, please check the Baud Rate Error which MCU generating, remember Hyperterminal have wide error handling, seen cases upto 20% baud rate error Hyperterminal can handle and decode, where as SIM900 or other MCU will fail.
I don't think this would be the problem. Because MCU is printing the AT Commands as desired when connected with PC (Hyper Terminal). I've attached the Screen Shots of Commands both as Characters and Hex in my previous posts.

Thanks a lot. Hope the problem will be solved soon.
 

Attachments

  • sim900_rs232_gsm_modem_opn.pdf
    532.5 KB · Views: 163

alexxx and mpathma,
Thank you very much for your support. Now am able to send message. Slight changes in my code helped me. As alexxx was telling from before I should have tried to listen to Modems Responses and mpathma was also right, I checked the schmatic more than twice and finall understoo that the wires were routed wrongly. By tmrw I'll post the final code for sending messages using ATmega32 and SIM900. Hope it would be useful for those who are struggling with the same. Now I should try to display received messages on the LCD. Thank you once again guys. :D ;)

---------- Post added at 20:42 ---------- Previous post was at 20:42 ----------

alexxx and mpathma,
Thank you very much for your support. Now am able to send message. Slight changes in my code helped me. As alexxx was telling from before I should have tried to listen to Modems Responses and mpathma was also right, I checked the schmatic more than twice and finall understoo that the wires were routed wrongly. By tmrw I'll post the final code for sending messages using ATmega32 and SIM900. Hope it would be useful for those who are struggling with the same. Now I should try to display received messages on the LCD. Thank you once again guys. :D ;)
 

Code:
//*SIMTV1 Trail code for ATmega32 with SIM900 Module*//
//* KUTHSAV*//
/*VIT University, Vellore*/
/*Compiler: CodeVisionAVR*/
//*Includeing Header Files Required*//
#include <mega32.h>
#include <stdio.h>
#include <stdlib.h>
#include <delay.h>
//*Declaring LCD PORT as PORT B*//
#asm
    .equ __LCD_PORT=0x18; PORTB
#endasm
#include <lcd.h>
#define baud 0x33;				 /* Baudrate=9600 at 8Mhz IRC Oscillator*/
#define UCB 0xD8;				 /*Enabling TXIE, RXIE TX and RX*/
#define LF 0x0A;  				/* Line feed */
#define CR 0x0D; 				 /* Carriage Return*/
#define SUB 0x1A; 				/* CTRl+Z*/
/*Declaring Global Variables*/
unsigned char si=0,qi=0,i=0;
char q[160];
char ch;
void usart_init(void);
void gsmcmd(char *s);
void sendmsg(char *s);
void usart_init(void)
{
UCSRA=0x00;
UCSRB=UCB;
UBRRH=0x00;
UBRRL=baud;
}
interrupt [USART_TXC] void usart_transmit_isr(void)
{if(qi!=si)
UDR=q[si++];
}
void gsmcmd(char *s)
{
qi=0;
si=1;
while(*s)
{q[qi++]=*s++;
}
q[qi++]=CR;  /*Appending Lines with Carriage Returns*/
UDR=q[0];
}
void sendmsg(char *s)
{
qi=0;
si=1;
while(*s)
{q[qi++]=*s++;
}
q[qi++]=SUB;
UDR=q[0];
}   
interrupt [USART_RXC] void rx_isr(void)
{
ch=UDR;
if((ch!=0x0A)&&(ch!=0x0D))
{
lcd_gotoxy(i,0);
lcd_putchar(ch);
i++;
}
if(i>3)
{i=0;
}
}
void main(void)
{
lcd_init(16);				/*lcd initialization*/
delay_ms(100);
#asm("sei")				/*set enable interrupts*/
usart_init();				/*initializing USART*/
gsmcmd("AT");
delay_ms(5000);
gsmcmd("AT+CMGF=1");
delay_ms(5000);
gsmcmd("AT+CSMP=17,167,0,241");
delay_ms(5000);
gsmcmd("AT+CMGS=\"95668xxxxx\"");	//*Mobile number*//
delay_ms(4000);
sendmsg("Jai Gurudev");			//*message that you want to send*//
delay_ms(2000);
}


So here is the code for sending messages using SIM900 and ATmega32. Now Guys I may need some help with displaying received messages.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top