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.

help with interfacing pic to GSM program

Status
Not open for further replies.

kemystri

Junior Member level 2
Joined
Feb 13, 2008
Messages
20
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,446
pic gsm

i had a problem poh

i made a module wherein it purpose is to communicate with GSM module

we tried the module using hyperterminal and it works properly

but when we try to connect it to gsm module, it seems that the command or ascii code that we were sending doesnt

recieve by the gsm module.

what was our problem?

is there a correct braud rate for the gsm module? accrding to the spec its auto baud rate

should we use the 9 bit?

whats wrong with our aproach?

whats with interrupt?

heres the our program

;*****************************************************************;
; REAL-TIME GROUP ;
; Test Program for USART ;
; Date Created: January 17, 2008 4:00 PM ;
; ver 1.0 ;
;*****************************************************************;

list p=16F877; list directive to define processor
#include <p16F877.inc>; processor specific variable definitions


__CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _XT_OSC & _BODEN_OFF & _LVP_OFF

DataByte equ 20h
TEMP2 equ 21h
DELA1 equ 22h
DELA2 equ 23h
DELA3 equ 24h
TEMP_PORTA equ 25h

loop_delay_char equ 26h


org 00h

;************************************
; Set Up the Baud Rate of the
; USART to 9600 bps
;************************************
BANKSEL SPBRG
movlw d'25'
movwf SPBRG
BANKSEL TXSTA
bsf TXSTA,BRGH


;************************************
; Set Up the The Reception of Data
; Continuous Reception is enabled
;************************************
BANKSEL TXSTA
movlw B'00100100'
movwf TXSTA
BANKSEL RCSTA
movlw B'10010000'
movwf RCSTA

bcf status,rp0
bcf status,rp1

BANKSEL TRISB
bcf trisb,7
bcf trisb,5
bcf trisb,3

BANKSEL TRISA
bsf TRISA,3
bcf TRISA,0
bcf TRISA,1
bcf TRISA,2
movlw d'6'
movwf ADCON1

BANKSEL PORTA
bcf PORTA,0
bcf PORTA,1
bcf PORTA,2

START
banksel PORTb
bcf portb,3
BANKSEL PORTA
movf PORTA,w
movwf TEMP_PORTA
bsf TEMP_PORTA,0
bsf TEMP_PORTA,1
bsf TEMP_PORTA,2
movf TEMP_PORTA,w
BANKSEL PORTA
movwf PORTA
call delay
btfss TEMP_PORTA,3
goto START

bcf TEMP_PORTA,0
bcf TEMP_PORTA,1
bcf TEMP_PORTA,2
movf TEMP_PORTA,w
BANKSEL PORTA
movwf PORTA


;==================================
;change hexadecimal to text mode
;==================================
call delay
call delay
call delay
banksel PORTb
bsf portb,3

movlw h'61'
call sub_sendByteToPhone
call loop_tx


movlw h'74'
call sub_sendByteToPhone
call loop_tx


;================================
;test if ok?
;we checked if we recieve a "ok" reply from the gsm
;================================

SEND_O2
call loop

movf DataByte,w
addlw -a'O'
btfss STATUS,Z
GOTO SEND_O2
banksel pir1
bcf PIR1, RCIF ;clear the character present flag
banksel PORTb
bsf portb,7


SEND_K2
CALL LOOP
movf DataByte,w
addlw -a'K'
btfss STATUS,Z
GOTO SEND_K2
banksel pir1
bcf PIR1, RCIF ;clear the character present flag
banksel PORTb
bcf portb,7
bsf portb,5

goto start

sub_sendByteToPhone
BANKSEL TXREG
movwf TXREG
return


;========================
;normal delay
;========================

delay
movlw d'1'
movwf dela3
loop3
movlw d'20'
movwf dela2
loop2
movlw d'20'
movwf dela1
loop1
nop
nop
nop
decfsz dela1,f
goto loop1
decfsz dela2,f
goto loop2
decfsz dela3,f
goto loop3
return

;========================
;delay for enter
;========================

;========================
;delay for chracters
;========================

delay_char
movlw d'1'
movwf dela3
loop3_char
movlw d'20'
movwf dela2
loop2_char
movlw d'20'
movwf dela1
loop1_char
nop
nop
nop
decfsz dela1,f
goto loop1_char
decfsz dela2,f
goto loop2_char
decfsz dela3,f
goto loop3_char
decfsz loop_delay_char,f
call delay_char
return

var_char
movlw d'5'
movwf loop_delay_char
return


Loop

BANKSEL PIR1
btfss PIR1, RCIF ;wait for receive character set
goto Loop ;nothing there


readByteFromPhone
;put data received from RCREG
;to W register and DataByte register
BANKSEL RCREG
movf RCREG,W
BANKSEL DataByte
movwf DataByte
return

Loop_tx
BANKSEL PIR1
btfss PIR1,TXIF
goto Loop_tx
return


end
 

dtr dcd site:edaboard.com

Hey, first if your program is going to be a big and complex one in the future, I advise you to switch to C.Use PIC-C Compiler.I don't understand why people write code in Assembly language when they are interfacing GSM module.I have seen many circuits, in which microcontroller were interfacing the GSM modems, I have never found a single application, where there is specially need for such a high speed, where they need to write program in Assembly.

Thirdly, I haven't read your assembly program, but I must tell you that, there's one more thing which you have to understand and that's the Serial Cable.I have had the similar kind of problem.

The cable by which you interface your GSM module with HyperTerminal is different
The cable by which you interface your GSM module with PIC will be different

The cable that you use with GSM module and with Hyper Terminal has no cross over connection, but when GSM module and PIC will be communicating, RTS and CTS pins should be short at the GSM module side, additionally TX and RX must be swap.I have given you the hint, that's the only way your PIC would communicate with GSM module.I myself have wasted so much time in it, until I discovered this remedy.
If still you're unclear, let me know.I'll tell you how to do it.

Autobauding option is another PROBLEM with communication, when autobauding is enabled, the GSM uses other pins for communications rather than just TX,RX which create another issues.So what you have to do, is that make baud rate constant of your GSM module, there will be AT command for doing this, after this YOU JUST SAVE THIS INFORMATION INTO THE GSM MODULE FLASH.Or else, you still won't be getting the correct results.There are so many little things, that are necessary for making successfull communication.
 

gsm to pic

umery is right, for communications and string manipulations C is better, compilers can generate ASM listing if you need it.
 

pic gsm interfacing

@penuy_balut

wat do u mean by "compilers can generate asm listing"?

u mean a translator by some sort? like ASM to C?

@emery

sry for using assembly, its because our school taught us only about assembly when using PIC

we never had an experience or getting a view of using C in our programs, so thats why!

The cable that you use with GSM module and with Hyper Terminal has no cross over connection, but when GSM module and PIC will be communicating, RTS and CTS pins should be short at the GSM module side, additionally TX and RX must be swap.I have given you the hint, that's the only way your PIC would communicate with GSM module.I myself have wasted so much time in it, until I discovered this remedy.
If still you're unclear, let me know.I'll tell you how to do it.

if u please. explain about it :cry:

Autobauding option is another PROBLEM with communication, when autobauding is enabled, the GSM uses other pins for communications rather than just TX,RX which create another issues.So what you have to do, is that make baud rate constant of your GSM module, there will be AT command for doing this, after this YOU JUST SAVE THIS INFORMATION INTO THE GSM MODULE FLASH.Or else, you still won't be getting the correct results.There are so many little things, that are necessary for making successfull communication.

ok, ill try to find that AT command to set the baudrate, but regarding the save setting which one? i scroll the AT commands for GSM module but i havent seen this type of command
 

gsm modem with circuit diagram

Upload the manual of your GSM module AT commands, I'll tell you which one.Or give me the link to it.

This is how you need to do, this is what I remember.Right now, I can't find my file in which I have drawn the diagram, so when ever I need it I can have a look at it.
WHY DOING THIS:
============
You use PIC with asynchronous communication and only use TX,RX pins for communications, on the other hand GSM modem uses TX,RX,CTS,RTS,etc pins for using.This cable is made on null-modem configuration.Your GSM modem sends the signal RTS(Request to Send) and as the pin is short, the signal itself is recieve by the GSM as CTS(Clear to Send).So it's a kind of trick in fooling the GSM modem, as if using CTS and RTS for communication.

93_1204467341.jpg


You have to made this kind of cable and RTS,CTS side should be on the Modem side.One side is dedicated to PIC and other side to GSM modem.If you overlap it, it won't work.
 

pic gsm program

do not forget to connect the ground specially when they are operating on separate power source
 

pic to gsm connection

hi mr emery

your block diagram is for serial cable?

do i need to use max232 to connect the serial cable to pic? or direct ahead?

my m22 benq module has a dual feature of TTL and rs232 serial cable, so which u are prefer?

by the way to hav u an idea, here wat we did

we set up a circuit wherin in composed of pic16f877 and max232

we connect the the pic and max232 for us to hav a serial cable connection.

we set a program for the pic to test it to the hyperterminal, by the way it goes

it works just fine but when we connect it to the benw m22 module it seem that it

wont establish a connection because the Led that signal a connection doesnt turn on

i just tell this because i confused in ur block diagram, it seem that the cable is directly connected to the pins of PIC.. am i wrong? or correct?



btw heres the link for the command

ftp://ftp.efo.ru/pub/benq/M23 AT.pdf
 

gsm pic program

Yes, you have to placed MAX232 converter between PIC and GSM modem, but as a matter of fact, you can connect them directly too, but your PIC would be more suspectible to damages, PIC has diode protection on its pins and the max. is around 15Volts, RS232 uses around 3 and 12V as I remember.So you can directly use it, but it's not recommended.

Added after 3 minutes:

we set a program for the pic to test it to the hyperterminal, by the way it goes

it works just fine but when we connect it to the benw m22 module it seem that it

wont establish a connection

This is it, what I'm saying.It won't establish the connection, not in any case.The reason is that for your benw m22 module and to your computer serial port.The TX pins and RX are NOT CROSS OVER, but when your PIC and benw m22 module will be communicating they need cross over TX and RX.The cable that you use with PIC and Computer won't work, you have to make the cable in the way as I have mention.
 

gsm with pic

ok sir, by the way.. what is the AT command for setting baud rate at saving setting?

thnx

Drawing1.jpg


are my connections are correct?
 

sample gsm programs

Upload the document of your modem, I have to read which AT command will do that, because for different GSM modems, we have different AT commands.

Some AT commands are special and only runs on specific products, some are more general commands that can be run on different modems.
 

m22 pic rx tx

thnx sir for the pdf u made.

heres the AT commands sir emery

i find it in the older post in this forum




and sir try to look at page 18-23 of this m22 design guide.

should i also short the dsr and dtr?
 

null modem gsm cable female female d 9 picc

I think it must be given in DTE-DCE local flow control at page 163.
But pages are missing in AT command file from Page 160-166

By pin number on DB-9, I don't remember which one is DSR and DTR, I'm sure they are shorted in the diagram which I have given you in the PDF file.Those serial cables designs are tested and they work.

The theme is that you won't use Hardware Flow Control communication and neither the Software Flow Control XOR/XNOR.You won't use Flow Control, so that you don't need CTS,RTS,etc.It is important where a GSM modem is working at different baud rate and your PIC is working at a different baud rate.To make communication possible, such pins are necessary.

But over here same baud rate will be set for GSM modem and PIC.Some pins will be shorted at the GSM modem side, so as to make it think it's in fully controlled co-ordination with PIC.Where as you'll use only TX and RX pins for communcation with GSM.
 

pic modem gsm cts rts

umery2k75 said:
I think it must be given in DTE-DCE local flow control at page 163.
But pages are missing in AT command file from Page 160-166

By pin number on DB-9, I don't remember which one is DSR and DTR, I'm sure they are shorted in the diagram which I have given you in the PDF file.Those serial cables designs are tested and they work.

The theme is that you won't use Hardware Flow Control communication and neither the Software Flow Control XOR/XNOR.You won't use Flow Control, so that you don't need CTS,RTS,etc.It is important where a GSM modem is working at different baud rate and your PIC is working at a different baud rate.To make communication possible, such pins are necessary.

But over here same baud rate will be set for GSM modem and PIC.Some pins will be shorted at the GSM modem side, so as to make it think it's in fully controlled co-ordination with PIC.Where as you'll use only TX and RX pins for communcation with GSM.

sir i found out that the rts and cts of the modem are not connected to the serial cable features of the GSM module. ive look into its schematic diagram try to look at it.

ive worked with ur connection and it still doesnt work fine. T.T
 

pic gsm interfacing circuit diagram

This is the standard way in which GSM modem connection is made with DB-9 connector.



Did you short the Pin 7,8 (RTS and CTS) and 1,4,6(DCD,DTR,xxx)?

ive worked with ur connection and it still doesnt work fine. T.T

Did you try with or without shorting RTS,CTS and DCD,DTR together?
 

benq m22 diagram

umery2k75 said:
This is the standard way in which GSM modem connection is made with DB-9 connector.



Did you short the Pin 7,8 (RTS and CTS) and 1,4,6(DCD,DTR,xxx)?

ive worked with ur connection and it still doesnt work fine. T.T

Did you try with or without shorting RTS,CTS and DCD,DTR together?

try to look at the schematic sir, i found out that only RX and TX are internally connected to the main SMS hardware
 

pic with gsm

I have seen the schematic, I don't know why RTS,CTS,DTR,DCD are not connected to DB-9 connector.It should be.
Anywayz, tell me when you connect PIC with hyperterminal, were you getting the output.If Yes, this would only work if:

1)TX on PIC side is short with TX on Computer side.
2)Pins of RTS,CTS,DTR,DCD must be short on Computer Serial Port side.

If Point 1 and 2 are correct then you should see the ouput on hyperterminal.
If you are only using TX,RX for sending the data to computer side(hyperterminal), then in no way you should see the output on it, hyperterminal make use of such pins like RTS,CTS,DTR,DCD.

Either you have some settings done on hyperterminal or you have pins already shorted in your serial cable.
Check your pin mapping, as I have told you in the PDF file, by using the needle,or whatever, check pin mapping and tell me.This problem is easy, I am getting curious about it now...
 

to write gsm program you must

in my circuit sir, i only connected in the DB9F is the TX RX and GND

but inside the connecting wires for the hyperterminal i just dont know but

im using a regular FEMALE/MALE RS232 connector, the one used in printers etc.

so may circuit(RX,TX,GND) <----- M/F RS232 connector -----> COM1 port of PC (male)
 

how to program pic programmer egizmo

Slightly off the topic, where did you get that circuit? this circuit is not upto the standard as it doesn't have connection of RTS,CTS,DTR,etc to the DB-9 of the GSM modem connection.Is this a test board or something? Have you made this circuit on your own?.Because to be able to work properly, such pins must be connected to DB-9.So, How will you achieve your goal of connecting PIC to GSM modem? How will you learn , if this doesn't work out! Instead of learning, your time is spent on troubleshooting.You have to do some modification to this circuit.Did your school provide this circuit to you? It should not be given to them, school must rely on professional evaluation boards.
The first step toward learning GSM modem,is to purchase a professional GSM Modem Evaluation board.It will be a complete circuit containing GSM modem.Do your test on it, Communicate GSM modem with PIC, use evaluation board to gain understanding.Once you gain understanding, then the second approach is to buy the individual GSM module, then make another circuit that will contain the module only and then integrate everything on it(like your circuit).That's the approach which should be follow.It's a standard way of doing things or else you might end up in some problem, then at the point you won't know what the problem is? Is the problem with the circuit or is the problem with the program.
In your case, you have a doubt, you don't know whether the problem lies in the Software of PIC or the Hardware of Modem.So in your case, diagnosing problems are difficult and is only a wastage of time.If I would be in your case, I would know my hardware could have no fault in it, because I have a professional evaluation GSM modem circuit.If there's any problem, it would be in my controller software.It's pretty strange as you don't have RTS,CTS,etc pins connected to DB-9 connector.It's wrong! those pins must be connected.
 

pic c code for gsm

sir emery the schematic i provid is the schematic diagram of the benq m22 module i bought @ e-gizmo.

so deciding from its hardware connection, also me ignored the cts because

even the gsm module are connected internally with just TX and RX and GND.

so applying the cts rts short in my own circuit wont work.


im would really agree on ur suggestion on learning from the GSM modem evaluation board but i dont hav it and besides our thesis deadline is near to end. our deadline is in 2 wiks after now. :cry:
 

how gsm is interface with pic controller

even the gsm module are connected internally with just TX and RX and GND.

Who said that to you? If you are correct, then why do Modem manufacturers include those pins?
Tell me, can you do some modification, if yes, then do as I said.It would work else I don't know any other way, I have explained you the logic for doing this.You just connect those pins of modem on the DB-9 and that's it.Do the shorting,swaping in the wire.You won't change your circuit, your circuit would be the same except it would have other pins connecting on the DB-9 connector as TX,RX and GND.
Still you'll use only TX,RX for communication.Other pins will be loop back to the Modem, just to fool it,thinking it's talking to another modem.
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top