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.

Pls. check our code in simple texting using benq m23 gsm

Status
Not open for further replies.

jff_frncsc

Newbie level 3
Joined
Feb 5, 2010
Messages
4
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
manila, philippines
Activity points
1,337
Pls. check our code in simple texting using benq m23 gsm modem interface to pic16f877A...We use Mikrobasic in programming...We try to simulate our code and its working properly...We also try it to test in our circuit...We put an indicator each time the modem respond to the PIC... The first command until last shown in the indicator is correct but the problem is our mobile phone doesn't receive anything...can someone help us resolve the problem in our codes??

This is our code for simple texting:

program sending

dim out0 as sbit at RB0_bit
dim out1 as sbit at RB1_bit
dim out2 as sbit at RB2_bit
dim out3 as sbit at RB3_bit
dim out4 as sbit at RB4_bit
dim out5 as sbit at RB5_bit
dim out6 as sbit at RB6_bit
dim out7 as sbit at RB7_bit
dim receive as string[10]
dim var as integer
dim power_on as sbit at RC3_bit

TRISB=0
TRISC=0

initialization:

PORTB=0
PORTC=0
power_on = 1
Delay_ms(3000)
power_on = 0
Delay_ms(3000)

ADCON1=ADCON1 or $0F
CMCON=CMCON or 7

UART1_Init(1200)
Delay_ms(3000)

AT1:
UART1_Write_Text("AT") 'set sms into text mode
Delay_ms(3000)
UART1_Write(13) 'ENTER
Delay_ms(3000)
out0=1

while var=0
UART1_Read_Text(receive, "OK", 2) ' reads text until 'OK' is found
if (receive[1]="R") OR (receive[1]="X") then
UART1_Read_Text(receive, "ROR", 4)
goto AT1
else
var=1
end if
wend
out1=1
var=0

CMGF:
UART1_Write_Text("AT+CMGF=1") 'set sms into text mode
Delay_ms(3000)
UART1_Write(13) 'ENTER
Delay_ms(3000)
out2=1

while var=0
UART1_Read_Text(receive, "OK", 2) ' reads text until 'OK' is found
if (receive[1]="R") OR (receive[1]="X") then
UART1_Read_Text(receive, "ROR", 4)
goto CMGF
else
var=1
end if
wend
out3=1
var=0

CSCA:
UART1_Write_Text("AT+CSCA=") 'command for entering sms center's number
UART1_Write(34) 'quotation mark(")
UART1_Write_Text("+639180000101") 'sms center's number
UART1_Write(34) 'quotation mark(")
Delay_ms(3000)
UART1_Write(13) 'ENTER
Delay_ms(3000)
out4=1

while var=0
UART1_Read_Text(receive, "OK", 2) ' reads text until 'OK' is found
if (receive[1]="R") OR (receive[1]="X") then
UART1_Read_Text(receive, "ROR", 4)
goto CSCA
else
var=1
end if
wend
out5=1
var=0

send:
UART1_Write_Text("AT+CMGS=") 'command for entering sms center's number
Delay_ms(3000)
out6=1
UART1_Write(34) 'quotation mark(")
Delay_ms(3000)
out7=1
UART1_Write_Text("+639194136071") 'sms center's number
Delay_ms(3000)
out0=0
UART1_Write(34) 'quotation mark(")
Delay_ms(3000)
out1=0
UART1_Write(13) 'ENTER
Delay_ms(3000)
out2=0
while var=0
UART1_Read_Text(receive, ">", 2) ' reads text until '>' is found
if (receive[1]="R") OR (receive[1]="X") then
UART1_Read_Text(receive, "ROR", 4)
goto send
else
var=1
end if
wend
out3=0
var=0

UART1_Write_Text(" Hello") 'text message
Delay_ms(3000)
UART1_Write(26) 'ctrl+z
Delay_ms(3000)
out4=0

end.

Thanx a lot!!! We appreciate your concerns!
 

You need to add a Carriage Return to the end of each command you send. Also, those long delays may cause problems with some modems - you shouldn't need any delays!
 

    jff_frncsc

    Points: 2
    Helpful Answer Positive Rating
    V

    Points: 2
    Helpful Answer Positive Rating
i have another problem...it's about receiving txt messages..

GSM Man said:
You need to add a Carriage Return to the end of each command you send. Also, those long delays may cause problems with some modems - you shouldn't need any delays!

Thanx a lot GSM Man!!!! Our program for sending message is now working!!!

but i have another problem...using the hyperterminal, when i read the receive message by the gsm modem this set of characters appeared:

+CMT: "639054598524","Dave","10/03/10,11:46:17+50"
Off A Socket 'this is the text we type in the mobile phone

all i want to display is "Off A Socket" w/o the headers,time,sender's # etc..

is theres any command that can display only the text that you type in the mobile phone???

thanx a lot...:D
 

Re: i have another problem...it's about receiving txt messag

jff_frncsc said:
is theres any command that can display only the text that you type in the mobile phone???
NO, but it's simple enough to parse the message string out of the returned data
 

UART_Read_Text

[/quote] NO, but it's simple enough to parse the message string out of the returned data[/quote]

reply: how can i parse the message string?? can you give me a syntax code??

how can i do that with this returned data?:

+CMT: "639054598524","Dave",10/03/10,11:46:17+50"
Off A Socket

just give me an idea...:D

+tnx again!!

Added after 7 minutes:

with regards to this returned data again:

+CMT: "639054598524","Dave","10/03/10,11:46:17+50"
Off A Socket

how does the pic read this data?? does it continuously read the data from +CMT 'til Socket? or every line i need to write UART_Read_Text to read it?
 

There are many ways you can parse the returned data. One way is to read each line of data into a buffer until you get the <CR><LF>. If the first line is "+CMT:", you know that the next line of data will be the message.
 

Hullo friends, am using pic16f84 to send sms after detecting intrusion, what changes can i make on above code, pliz help me
regards
 

ermm... i need some help.
The commands you have in similar form:

UART1_Write_Text("AT+CMGS=") 'command for entering sms center's number
Delay_ms(3000)
out6=1
UART1_Write(34) 'quotation mark(")
Delay_ms(3000)
out7=1
UART1_Write_Text("+639194136071") 'sms center's number
Delay_ms(3000)
out0=0
UART1_Write(34) 'quotation mark(")
Delay_ms(3000)
out1=0
UART1_Write(13) 'ENTER

...You seem to have some UART functions specifically used for the GSM modem. I'd like to if you,re using a header file with gsm AT command functions? If yes i would really appreciate it if i could get a copy of the header file!
 

You need to add a Carriage Return to the end of each command you send.

The program written by jff_frncsc the carriage returns are added after the AT commands sent through controller, so where else are CRs required in this program?

I'm working on PICBASIC Proton IDE, (PIC16F877A) with M23 BenQ's GSM modem. I have written a very simple program inorder to avoid complications in the beginning but still, I'm unable to send SMS through modem :(

Code:
Device 16F877A
        XTAL = 4
        Dim Num As 12345678          ' Fixing my cell no.
                 
                
        TRISC = %10111111             ' Set TX (PortC.6) to output
        SPBRG = 6                           ' Set baud rate to 9600
        RCSTA = %10010000            ' Enable serial continuous receive
        TXSTA = %00100000            ' Enable transmit asynchronous mode
 
        DelayMS 5000
        HRSOut "AT+CMGS=" ,34
        HRSOut Num,34,13
        HRSOut "Hello" ,26
        End
 

After you send the phone number you need to wait for the module to send you a ">" indicating it is ready for the message. See the FAQ here: **broken link removed**
 

Hey GSM man, I still am not able to simply send a message! :( Here are the changes made with reference to the link you posted. Please help me in troubleshooting...


Device 16F877
XTAL = 4


TRISC = %10111111 ' Set TX (PortC.6) to output
SPBRG = 6 ' Set baud rate to 9600
RCSTA = %10010000 ' Enable serial continuous receive
TXSTA = %00100000 ' Enable transmit asynchronous mode

HRSOut "AT+CMGF=1", 13
HRSin Wait ("OK")
DelayMS 2000
HRSOut "AT+CMGS=",34,"123456789",34,13 '123456789 my cell phone no.
HRSin Wait (">")
HRSOut "Hi",26,13
End
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top