PDA

View Full Version : GSM modem not working with PIC! Both modem & PIC work fine with PC



financecatalyst
- 29th April 2010, 11:01
I am trying to connect my GSM modem sim300 with my PIC 16F877A but it is not working. I tried my modem with few AT commands with my PC and it works fine. I tried communicating with my PIC using my PC and it worked fine. BUT everything stops working when I connect my PIC to my Modem.
I use MAX 232 converter. Connection are as follows:

PIC PortC.6 ---> MAX 232 Pin-11
PIC PortC.7 ---> MAX 232 Pin-12

Modem Pin2 - Max 232 Pin-13
Modem Pin3 - Max 232 Pin-14

Modem Pin5 - Common Ground with PIC

My code is as follows:



DEFINE OSC 4
ADCON1=7
CMCON=7
INTCON=0
OPTION_REG.7=0
TRISA=0 : PORTA=0
TRISB=0 : PORTB=0
TRISC=%10000000 : PORTC=0
TRISD=0 : PORTD=0
TRISE=0 : PORTE=0
CCP1CON=0

DEFINE DEBUG_REG PORTC
DEFINE DEBUG_BIT 6
DEFINE DEBUG_BAUD 4800
DEFINE DEBUG_MODE 0

DEFINE DEBUGIN_REG PORTC
DEFINE DEBUGIN_BIT 7
DEFINE DEBUGIN_MODE 0

high portb.7

check:
DEBUG "AT",13,10
DEBUGIN 5000,check,[WAIT("OK")] : pause 500
Low PortB.7
end


As you can see in the code, upon receipt of "OK" Led at portb.7 should go low, but it never does.
I don't know if I am communicating right with right connections and baud rate settings or my modem is faulty (can't be as it works with my PC:) )
When I connect the Modem to my PIC I do have to make sure in Flow-control option "Hardware" is selected, otherwise I don't see anything on my Hyperterminal screen.

I searched on the net about disabling this option and I found one command "AT+IFC=0,0". I tried that as well but it is still not working with my PIC.

financecatalyst
- 30th April 2010, 06:10
Any-one there - Please help

I also tried replacing Max232 - but no results. Do I need to put another pin Ground of the modem, I am only using pin 2/3/5 (Tx/Rx/Gnd) of the modem while connecting wih the PIC.
I also tried fliping Tx with Rx but no results still.

ScaleRobotics
- 30th April 2010, 06:45
If both can talk to your computer through a max232, then they are both ttl devices. Pull the max232 out, and connect tx to rx and rx to tx and see what happens. Make sure they are both on the same voltage.

Walter

financecatalyst
- 30th April 2010, 12:59
Thanks for the answer. The problem is that I am using a complete modem. I am sure it has MAX232 inbuilt. I just have to connect the rs232 serial cable to it and my pc. I cannot take out MAX232 from the modem.
It's pin 2 (DB9-connector) has a voltage of -5.85V.

Is it possible that I have to put more pins ground apart from pin5 of DB9-Connector? Thanks

Ioannis
- 30th April 2010, 13:53
Although I am sure it works on PC with just TX, RX nd Gnd, have tried to connect to PC just with these 3 wires?

Also are you sure about 4800 baud?

Ioannis

financecatalyst
- 30th April 2010, 16:44
Although I am sure it works on PC with just TX, RX nd Gnd, have tried to connect to PC just with these 3 wires?

I tried it now, I could not type in my hyperterminal anymore as soon as I connected my modem to the PC with only 3 wires. As soon as I connected 9 pin serial cable, everything starts working fine.



Also are you sure about 4800 baud?

Yes, baud rate is 4800.

aratti
- 30th April 2010, 17:05
I tried it now, I could not type in my hyperterminal anymore as soon as I connected my modem to the PC with only 3 wires. As soon as I connected 9 pin serial cable, everything starts working fine.


Was hyperterminal in hand shaking mode?

See the modem manual, if the modem is in handshaking mode by default, in such a case you have to set it for no flux controll.

Al.

financecatalyst
- 30th April 2010, 20:27
Was hyperterminal in hand shaking mode?

See the modem manual, if the modem is in handshaking mode by default, in such a case you have to set it for no flux controll.

Al.
I have not got the manual but I have opened the modem and saw that sim300 is the module which the modem is built on. I have checked sim300 datasheet but could not understand many things as I do not have too much of a technical background.

Can you advise me, what AT commands can do this job.
I also find this on the net - http://www.london-electronics.com/alpha_232_conns.gif
Is this an alternate way to go to solve this problem (RTC - CTS connected together & also pins 6,1,4 connected together? I do not want to try it unless it is safe to do so, only have 1 modem :)

Also, how can I find out if Hyperterminal is in Handshaking mode? One more thing I would like to mention here which I read from sim300 datasheet is that the modem supports and by default has Autobaud from 1200 to 19200.

aratti
- 30th April 2010, 21:16
Also, how can I find out if Hyperterminal is in Handshaking mode?

When you set the baud rate you can set also the flow mode. See the three snaps attached.

Al.

financecatalyst
- 1st May 2010, 04:43
When you set the baud rate you can set also the flow mode. See the three snaps attached.

Al.

No, the handshake mode is "None".

falingtrea
- 3rd May 2010, 19:01
The setting of hyperterminal may not tell you whether the modem itself needs flow control . Typically if flow control is turned off, the RTS pin is set "high".

One thing you can try is either to set no flow contol on the SIM300(if you can), or wire an output RS232 buffer to pin 7 of the serial cable and pull the input low, which should make the RTS active on the SIM300.

Kolesnikov
- 12th May 2010, 09:31
This is a feature of the sim300 module. If you connect it via 3 wires then you have to connect its RTS with CTS - these are pins 7 and 8 on the DB9 RS232.