View previous topic :: View next topic |
Author |
Message |
frustrated Guest
|
sms |
Posted: Mon Mar 27, 2006 7:41 am |
|
|
can anyone point out what i am doin wrong, this is really starting to bug me i am following at commands but when i blast the pic with this code it seems to work but when pic and modem are connected nothing happens, i am at a loss, any constructive comments welcome
Code: |
#include <16F877.h> /* Defines chip */
#include <stdio.h> /* this gets the printf() definition */
#use delay(clock=4000000)
#fuses hs, noprotect, nowdt, nolvp
#use rs232(baud=9600,xmit=PIN_C6, rcv=PIN_C7, stream=GSM, ERRORS)
const int CR=0x0d;
const int CZ=0x1A;
void main()
{
fprintf(GSM,"AT\r\n");
delay_ms(5000); /* checks are they communicating */
fprintf(GSM,"AT+CMGF=1\r\n"); /* sends an at command reay to send */
delay_ms(5000); /*sends a carriage return */
fprintf(GSM,"AT+CMGS=\"07712121212\""); /* sents the following text to this number */
fputc(CR,GSM);
delay_ms(5000);
fprintf(GSM,"Hi world"); /* the text that will actually be sent */
delay_ms(5000);
fputc(CZ,GSM); /* sends carriage return */
}
|
|
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Mar 27, 2006 1:59 pm |
|
|
At a minimum, you need to add a while(1) statement at the end of main().
This will prevent the PIC from executing the hidden SLEEP instruction
which is placed there by the compiler. If the PIC goes to sleep, your
"CZ" character will never be sent. Add the line shown in bold below:
Quote: |
delay_ms(5000);
fprintf(GSM,"Hi world");
delay_ms(5000);
fputc(CZ,GSM);
while(1);
}
|
Also, you don't have to use traditional C comments. Use the // style.
You can type in code much faster that way. |
|
|
frustrated Guest
|
|
Posted: Tue Mar 28, 2006 12:37 pm |
|
|
thanks PCm but this still does not work i heard that you must send each character individually is this true, any more help on why this will not work |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Tue Mar 28, 2006 3:55 pm |
|
|
If you connect the PIC to a PC, do you then see the expected messages?
Does the modem work when you connect it directly to a PC? |
|
|
frustrated Guest
|
|
Posted: Tue Mar 28, 2006 4:09 pm |
|
|
not quite it seems to work but when the send message command the character ">" does not come up so i know that the code isnt working, im at a total loss |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Tue Mar 28, 2006 5:22 pm |
|
|
frustrated wrote: | not quite it seems to work but when the send message command the character ">" does not come up so i know that the code isnt working, im at a total loss | Sorry, I don't understand what you mean. You say 'it seems to work', but what is 'it'? The PIC, PC or the modem?
Try to narrow down the problem. Make 100% sure it is either the PIC or modem failing by connecting them to a PC. When you connect the PIC to a PC, and you don't see the expected messages than you know the PIC is failing. Try similar by connecting the modem to a PC. |
|
|
Chicky
Joined: 04 Aug 2005 Posts: 21
|
|
Posted: Wed Mar 29, 2006 1:34 am |
|
|
maybe u can try this:
Code: | fprintf(GSM,"AT+CMGS=\"07712121212\"");
fprintf("\n"); >> this is the same as CR |
i use this when i interface my pic to siemens m50...
but the code is slightly diff, as i'm not using gsm modem but hp...
also try this:
Code: | printf("at+cmgs=?\r");
delay_ms(1000); |
if ur modem answer with OK, then its ready to send sms...
and why dont u use hyper terminal and simulate ur AT commands?
after successful, just convert the code to C and substitute hyperterm with PIC...
hope this help |
|
|
arunb
Joined: 08 Sep 2003 Posts: 492 Location: India
|
RE: |
Posted: Wed Mar 29, 2006 7:17 am |
|
|
Hi,
If the PIC works well with the PC then it should also work with the modem..
thanks
arunb |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
Re: RE: |
Posted: Wed Mar 29, 2006 7:19 am |
|
|
arunb wrote: | Hi,
If the PIC works well with the PC then it should also work with the modem..
thanks
arunb |
If the PIC works with the PC then you will need a crossover cable with the modem. |
|
|
frustrated Guest
|
|
Posted: Wed Mar 29, 2006 8:49 am |
|
|
i have done all this, i used the commands specified by the manufacturer, i then made my code suitable to implement these commands. when i put the command printf and then put the command in as a string. i even modified the code to put one char in at a time, but it only enters the a command.
I also heard that the echo function was on the modem i had this disabled and still no joy, i really appreciate all ur help tho, any more suggestions tho? |
|
|
khawer102
Joined: 14 Mar 2006 Posts: 9 Location: Pakistan
|
|
Posted: Wed Mar 29, 2006 10:03 am |
|
|
I have the exact similar problem. my PIC communicates fine with the PC and my modem works fine too. but when i try to communicate modem with PIC it does not work.
i bought a gender changer which changes male-female serial cable to male-male. but it does not make any difference.
frustrated if you come up with some solution plz tell me about it too. i am working on the same and if i have any success i wil inform you about it too. |
|
|
rberek
Joined: 10 Jan 2005 Posts: 207 Location: Ottawa, Canada
|
|
|
frustrated Guest
|
|
Posted: Wed Mar 29, 2006 12:23 pm |
|
|
was talking to a lectuter today he said it is probably the cable as the previous post pointed out
male(millenium dev board) female (modem)
------------------------------------------------------------------------------------
the problem he said was that the millenium board did not use a crossover cable tx pin2 was also tx on what is supposed to be the rx. he suggested making own serial cable, any wiring diagrams or other solutions appreicated.
thanks i will post a solution if it arrives |
|
|
echo Guest
|
|
Posted: Wed Mar 29, 2006 1:04 pm |
|
|
how do you cope with the acks back from the modem |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Wed Mar 29, 2006 9:49 pm |
|
|
frustrated wrote: | was talking to a lectuter today he said it is probably the cable as the previous post pointed out
male(millenium dev board) female (modem)
------------------------------------------------------------------------------------
the problem he said was that the millenium board did not use a crossover cable tx pin2 was also tx on what is supposed to be the rx. he suggested making own serial cable, any wiring diagrams or other solutions appreicated.
thanks i will post a solution if it arrives |
NULL MODEM cable. |
|
|
|