![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
Ed_Banses
Joined: 15 Sep 2005 Posts: 15
|
GSM problems with AT commands |
Posted: Tue Nov 22, 2005 4:14 pm |
|
|
Hi everybody,
I am starting a project trying to communicate a PIC16F877A with a GSM modem Fargo Maestro 100.
I want to send a message and I can do it by using a PC connected by hyper terminal with the modem.
The problem arrives when I try to connect the PIC with the MODEM, y cannot send the message, there is teh code:
#include <16f877A.h>
#device ICD=TRUE
#fuses HS,NOLVP,NOWDT,PUT
#use delay(clock=20000000)
#use rs232(baud=115200, xmit=PIN_C6, rcv=PIN_C7, bits=8, stream=GPS)
const int CR=0x0d;
void main() {
fprintf(GPS,"AT+CMGF=1");
fputc(CR,GPS);
fprintf(GPS,"AT+CMGS=\"+44788614354\"");
fputc(CR,GPS);
delay_ms(1000);
fprintf(GPS,"Hi world");
fputc(0x1A,GPS);
delay_ms(1000);
putc(CR);
}
Thanks a lot just for reading.
Looking forward any idea.
Eduardo |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah Guest
|
|
Posted: Tue Nov 22, 2005 4:24 pm |
|
|
Add ERRORS to the RS232 statement. Though it doesn't matter at present, the UART receive side will be 'hung' after the code, since the incoming data has not been processed.
Add:
while(true);
After your last putc, otherwise the last characters will never be sent, as the PIC will run off the end, and go to sleep.
Why are you using 'putc' here, not fputc?.
Seriously, look at your hardware. Remember that the PC, generates RS232, while the PIC develops TTL serial. You need signal inversion, and level shifting to match what the PC generates.
Best Wishes |
|
![](templates/subSilver/images/spacer.gif) |
Ed_Banses
Joined: 15 Sep 2005 Posts: 15
|
|
Posted: Wed Nov 23, 2005 6:43 am |
|
|
Thanks a lot for the reply Ttelmah
I have just included the task in a while loop, the sms should be sended when I press a button and wait until the next time I will press it.
In addition to this I changed the last putc with a fputc.
But the application is still not working.
Could you tell me how can I add the ERRORS to the RS232 statements?
Can I use the virtual RS232 of the ICD-4000 as a monitor for the messages of the modem?
Thanks a lot.
Eduardo |
|
![](templates/subSilver/images/spacer.gif) |
arunb
Joined: 08 Sep 2003 Posts: 492 Location: India
|
RE: |
Posted: Wed Nov 23, 2005 7:13 am |
|
|
Hi,
How are you trying to receive the data from GSM. ??
You should use the receive interrupt for this, after the interrupt has occurred , you should read the entire string...
thanks
arunb |
|
![](templates/subSilver/images/spacer.gif) |
Foppie
Joined: 16 Sep 2005 Posts: 138 Location: The Netherlands
|
|
Posted: Thu Nov 24, 2005 1:36 am |
|
|
Ed_Banses wrote: | Could you tell me how can I add the ERRORS to the RS232 statements? |
Code: | #use rs232(baud=115200, xmit=PIN_C6, rcv=PIN_C7, bits=8, ERRORS, stream=GPS) |
|
|
![](templates/subSilver/images/spacer.gif) |
Ed_Banses
Joined: 15 Sep 2005 Posts: 15
|
|
Posted: Thu Nov 24, 2005 4:57 am |
|
|
Thanks a lot for your ideas, I will try them!!
I will tell you how is going everything.
Thanks a lot again,
Eduardo |
|
![](templates/subSilver/images/spacer.gif) |
r520m Guest
|
|
Posted: Thu Nov 24, 2005 7:03 am |
|
|
Hi
1.- Try to use baud=9600, up to 57600.
2.- Try to comunicate PC with 16F877 using 9600 up to 57600, using max232.
If your hyperterminal receives the chars sent, your PIC is working very well. So you will can comunicate PIC to modem.
3.- If you canīt receive data from PIC on PC, the hardware UART is not workink.
4.- Try to use "force_sw" in use rs232 definition, for UART pins be have a software behavoir.
5.- If 4 point not works, try use another pins of PIC...
6.- IN your code there is not rutine for receive data from modem, example, send AT<CR>, modem answers with AT....may be modem is working, but the code have faults...
An question:
Modem works in RS232 or TTL levesl?
Sorry for my bad english
Bye |
|
![](templates/subSilver/images/spacer.gif) |
r520m Guest
|
|
Posted: Thu Nov 24, 2005 7:18 am |
|
|
Hi again:
from www.fargo.com
Code: | Fargo Maestro 100 (GSM and GPRS Class 10)
The connection is made easily through the RS 232 interface.
Interface Connections:
-SIM holder
-15 pin Sub-D connector (serial and audio connection)
-4-pin power supply connector (micro-FIT 3.0)
-SMA antenna connector (50 ohm
|
It seems Maestro use RS232 levels, in fact, PIC use TTL levels...
So, you must use a level shifter first, like a MAX232 chip...you will get the glory with him.
A test, measure TX and RX pin respect ground...you will get + and - levels..thats mean you must use MAX232..
DB-15 pinout http://www.aggsoft.com/rs232-pinout-cable/modem-db9-to-db15.htm
- TX (12)
- RX (13)
- System Groung (1,8,15)
Bye |
|
![](templates/subSilver/images/spacer.gif) |
Ed_Banses
Joined: 15 Sep 2005 Posts: 15
|
|
Posted: Sat Nov 26, 2005 6:16 am |
|
|
Thanks a lot for your responses.
Unfortunately I am still without communication :(
I wrote the next code in order to check the communication with the modem:
Code: |
#include <16f877A.h>
#device ICD=TRUE
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=20000000)
#use rs232(baud=115200, xmit=PIN_C6, rcv=PIN_C7, bits=8, ERRORS, stream=GSM)
#use rs232(DEBUGGER, stream=DEBUG)
#define PUSH_BUTTON PIN_A4
const int CR=0x0d;
char escrito[40];
byte c;
wait_for_one_press()
{
while(input(PUSH_BUTTON));
delay_ms(200);
while(!input(PUSH_BUTTON));
}
void main() {
while(TRUE){
wait_for_one_press();
fprintf(GSM,"AT");
fputc(CR,GSM);
fgets(escrito,GSM);
fprintf(DEBUG, "\r\n\%s",escrito);
}
}
|
The problem is that I cannot receive the "OK" from the modem, PIC is trying to read the response but nothing arrives to it.
I checked with hyperterminal and everything looks fine.
I would appreciate any idea about it.
Many thanks in advance
Eduardo |
|
![](templates/subSilver/images/spacer.gif) |
r520m Guest
|
|
Posted: Sat Nov 26, 2005 11:54 am |
|
|
First, tell us what are you doing, do you use max232 bettwen PIC and your modem?
Bye |
|
![](templates/subSilver/images/spacer.gif) |
Ed_Banses
Joined: 15 Sep 2005 Posts: 15
|
|
Posted: Sat Nov 26, 2005 12:18 pm |
|
|
Well, I am using the evaluation board of CCS for the PIC16F877 microcontroller.
Mainly is the PIC connected to a MAX232 and y connected the Max In/Out to the MODEM.
Thanks a lot.
Regards,
Eduardo |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah Guest
|
|
Posted: Sat Nov 26, 2005 3:23 pm |
|
|
A couple of obvious questions at this point. Ae you connecting the ground wire as well?. It is needed.
Are you sure you have the TX/RX connected the right way round?. Remember that the if the PIC is normally connected to the PC, it'll have it's 'TX' pin, connected to the PC's 'RX' pin, and vice versa. The Modem will be the same (they are both technically wired as DCE devices). You will actually need a 'null modem' cable, to allow the units to connect to each other.
Best Wishes |
|
![](templates/subSilver/images/spacer.gif) |
Victor
Joined: 27 Oct 2003 Posts: 12
|
|
Posted: Mon Nov 28, 2005 2:00 am |
|
|
To read incoming sms, I can use AT+CMGL, but I must poll it often.
Can I get any trigger message if there is new incoming SMS?
I am using TC35i.
Thank you. |
|
![](templates/subSilver/images/spacer.gif) |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|