PDA

View Full Version : TC35i GSM With PIC 16F690 help



financecatalyst
- 28th September 2009, 16:16
Hi
Can someone help me please providing a schematic to link up my PIC with TC35i GSM modem.

I have seen an schematic provided by Aratti, linking TC35i with 16F873.

What I would like to ask is why MAX232 is used? What does this IC actually do and why not to connect the PIC directly to the TC35i?

Damien

pedja089
- 28th September 2009, 17:41
max 232 is logic level converter. It converts RS232 logic level to ttl logic level and ttl to RS232. You should look datasheet.

financecatalyst
- 28th September 2009, 18:39
Thanks for the info but since I am fairly new to this field, can you guide me as to where I can read about TTL & RS-232 type signals and difference between them.

mackrackit
- 28th September 2009, 22:29
http://en.wikipedia.org/wiki/RS-232

http://en.wikipedia.org/wiki/Transistor%E2%80%93transistor_logic

Is a start...

pedja089
- 28th September 2009, 22:33
On google or wiki:)
RS232 standard:
logic "1" is -3 to -15V
logic "0" is 3 to 15v
-3 to 3 is not defined
TTL standard:
logic "1" is 2 to Vcc (usually Vcc=5V)
logic "0" is 0 to 0.8V
Edit:
0.8 to 2V isn't defied

financecatalyst
- 28th September 2009, 23:24
On google or wiki:)
RS232 standard:
logic "1" is -3 to -15V
logic "0" is 3 to 15v
-3 to 3 is not defined
TTL standard:
logic "1" is 2 to Vcc (usually Vcc=5V)
logic "0" is 0 to 0.8V
Edit:
0.8 to 2V isn't defied

Thanks. I am trying to send an SMS using TC35i & 16F690. I tried to replicate the schematic at this link: http://techni.caliti.es/blog/2008/12/sms-io-controller.html
I used the pins 10 & 12 of 16f690 instead of 17 & 18 of 16F873. Hope it will work :)

aratti
- 29th September 2009, 07:38
I used the pins 10 & 12 of 16f690 instead of 17 & 18 of 16F873. Hope it will work

If you have in mind to use the downloaded software, the answer is IT WILL NOT WORK.

If you will write your own software the answer is YES IT WILL WORK.

Al.

financecatalyst
- 29th September 2009, 09:58
If you have in mind to use the downloaded software, the answer is IT WILL NOT WORK.

If you will write your own software the answer is YES IT WILL WORK.

Al.

Hi Aratti, your project has inspired me to do one by myself. I wont be connecting to the computer (as it does not have an serial port) neither I can get 16F873 that easily. So I am using 16F690.

Any advise as to how to set up the registers, correctly for 690?

aratti
- 29th September 2009, 15:45
Any advise as to how to set up the registers, correctly for 690?

With pic 16F690 you need to turn off analog port to make them digital. You will accomplish this with the following instruction:


ANSEL = 0 : ANSELH = 0

In my project I have used 8 ports as inputs and 8 ports as output. 690 doesn't have all these ports available, so you will decide how many inputs and how many outputs to use. Remember to set the TrisA; TrisB and TrisC registers accordingly.


Al.

financecatalyst
- 29th September 2009, 16:20
Here is my code:

OSCTUNE=%01111 ' Oscillator 8MHz
intcon=0 ' Interrupts disabled
cm1con0=0 ' Comparator 1 disabled
cm2con0=0 ' Comparator 2 disabled
ansel=0 ' Pins to be Digital
anselh=0 ' Pins to be Digital
baud con 16468 ' baud rate = 9600 Inverted
trisc=%00000000 ' Port C I/O
trisb=%01111111 ' Port B I/O
trisa=%000000 ' Port A I/O
portc=0 ' Setting port c Low
portb=0 ' Setting port b Low
porta=0 ' Setting port a Low
i var byte ' Declaring variable
c var byte ' Declaring variable
tx var Portb.7 ' Declaring tx pin
rx var Portb.5 ' Declaring rx pin

Include "modedefs.bas"

main:
Serout2 tx,baud,["AT+CMGF=1",13]
gosub one
Serin2 rx,baud,5000,main,[wait("OK"),i]
gosub two
goto main

one:
for c=1 to 5
portc=255
pause 20
portc=0
pause 20
next c
return
two:
for c=1 to 5
portc=255
pause 400
portc=0
pause 400
next c
return

My Problems:

1) My led connected to portc only goes high ONCE in label one though it should enter label one every 5000mS.

2) It never enters label two as I assume there is somthign wrong in the communication part of PIC with the modem.

Please help me find out what am I doing wrong here?

aratti
- 29th September 2009, 17:07
It never enters label two as I assume there is somthign wrong in the communication part of PIC with the modem






main:
Serout2 tx,baud,["AT+CMGF=1",13]
gosub one
Serin2 rx,baud,5000,main,[wait("OK"),i]
gosub two
goto main




Remove the GOSUB One instruction! When you send an AT command to the modem, then you MUST immediatly switch to the SERIN2 instruction otherwise there is a high chance that the modem answer will be lost.

Edited:

baud con 16468 ' baud rate = 9600 Inverted

Looking to the PBP manual the correct setting for 9600 bauds is 84 not 16468

Did you use the MAX232 for connecting Pic to modem?

Al.

financecatalyst
- 29th September 2009, 17:54
Done it to 84, so now it is transmitting in True mode. NOW the code is entering gosub one as expected BUT not gosub two.
Changed the code to the following:
main:
gosub one
Serout2 tx,baud,["AT+CMGF=1",13]
Serin2 rx,baud,5000,main,[wait("OK"),i]
gosub two
goto main

As always code never enters label two which means it is not getting the required response. I attach my setup photo, though not very clear but the schematic is the same except the pin change to 10 & 12 instead of your 17 & 18.

pedja089
- 29th September 2009, 18:14
tc35i factory settings for bounrate is 2400 not 9600!
Becouse you use max its not inverted signal.
on 2400 and true settings should be 396 if you use 4mhz crystal.
here example of code how to star communication with modem if max232 is used:

Init:
serout tx,0,["AT",13]
serin2 rx,396,1000,init,[WAIT("OK")]

aratti
- 29th September 2009, 18:40
baud con 84 ' baud rate = 9600 Inverted
Rx var Portb.7 ' Declaring rx pin
Tx var Portb.5 ' Declaring tx pin



Change your code as per the above, then it should work.

Edited:
Remember to allow the modem to settle after powerup, before start serial communication (See modem led blink)
Al.

financecatalyst
- 29th September 2009, 18:40
tc35i factory settings for bounrate is 2400 not 9600!
Becouse you use max its not inverted signal.
on 2400 and true settings should be 396 if you use 4mhz crystal.
here example of code how to star communication with modem if max232 is used:

Init:
serout tx,0,["AT",13]
serin2 rx,396,1000,init,[WAIT("OK")]

Tried you way as well. I am using internal oscillator and I put it to 4MHz this time. After that I tried your instructions above but results are the same. Two questions I want to ask you
First: Why have you used "0" in the instruction serout tx,0,...
Second: why have you not used serout2 and used just serout & serin2 instead of serin?

financecatalyst
- 29th September 2009, 18:52
baud con 84 ' baud rate = 9600 Inverted
Rx var Portb.7 ' Declaring rx pin
Tx var Portb.5 ' Declaring tx pin



Change your code as per the above, then it should work.

Al.

No Luck still. In the datasheet, portb.5 is Rx & portb.7 is Tx! Why you advised to mark it the other way. Though it's still not working.
Also 9600 Inverted is NOT 84 (just looked into the PBP manual) it is 16468
Program is the same as above (With your modifications) i.e. Baud 84 & ports interchanged.

aratti
- 29th September 2009, 18:55
tc35i factory settings for bounrate is 2400 not 9600!

TC35i is autobauding from 4.8Kbps to 115Kbps. 2400 bauds setting will not activate the auto-function.

Al.

aratti
- 29th September 2009, 19:27
I think you need to check your modem with hyperterminal to check if it works correctly. If your computer doesn't have a serial port, you can obtain a serial to USB converter (check if compatible with your operating system)

Al.

financecatalyst
- 29th September 2009, 19:51
I think you need to check your modem with hyperterminal to check if it works correctly. If your computer doesn't have a serial port, you can obtain a serial to USB converter (check if compatible with your operating system)

Al.

I will try that hopefully tomm, and will post my findings. Thank you all for your help upto now.

financecatalyst
- 29th September 2009, 20:08
By the way, can someone tell me the expected voltages across 232 pins and modem Rx & Tx pin. I just have a funny feeling that problem is with the hardware part instead of software.

pedja089
- 29th September 2009, 22:09
Voltages shoul be about +/-10V.

First: Why have you used "0" in the instruction serout tx,0,...
Second: why have you not used serout2 and used just serout & serin2 instead of serin?
There no reason why i used serout.
0 is used to set bondrate to 2400T.
Set cursor to serout and pres F1, and everything is in help.
Program is working. I used to check conection with modem for my call & sms controller.
Code with status led:


Init:
toggle led1
serout tx,0,["AT",13]
serin2 rx,396,1000,init,[WAIT("OK")]
serout TX,0,["at&f",13]
pause 500
toggle led1
serout TX,0,["at+cmgf=1",13]
pause 500
toggle led1
serout TX,0,["at+clip=1",13]
pause 500
led1=1
Start:....
Led will flash every second if modem is'n connected.
While setting up modem led will flash every 0.5s.
When device is ready led stay on.

mackrackit
- 29th September 2009, 22:12
I am using internal oscillator and I put it to 4MHz this time.
The internal OSC most often is NOT accurate enough for communications. Try an external.

Look at post #5 for the expected voltage levels.

financecatalyst
- 29th September 2009, 22:40
Voltages shoul be about +/-10V.

There no reason why i used serout.
0 is used to set bondrate to 2400T.
Set cursor to serout and pres F1, and everything is in help.
Program is working. I used to check conection with modem for my call & sms controller.
Code with status led:


Init:
toggle led1
serout tx,0,["AT",13]
serin2 rx,396,1000,init,[WAIT("OK")]
serout TX,0,["at&f",13]
pause 500
toggle led1
serout TX,0,["at+cmgf=1",13]
pause 500
toggle led1
serout TX,0,["at+clip=1",13]
pause 500
led1=1
Start:....
Led will flash every second if modem is'n connected.
While setting up modem led will flash every 0.5s.
When device is ready led stay on.

After all day breaking my head - I have to say Many Thanks to all who have tried to help me and especially you for the code and Aratti (for hardware correction).
It is working now.

BUT as usual few questions to understand it better.
1) Why is it only working with serout & serin2 combination. I tried it with serout+serin & serout2+serin2 but it didn't work in this combination.

2)What is the actual difference between 0 & 396 when they BOTH are true baud 2400?
Thanks again

pedja089
- 29th September 2009, 22:54
It should be work with serout and serout2.
0 and 396...
look in help in mcs!!
396 is for serout2 and serin2
0 is for serin, serout...
you have tables in help...

aratti
- 30th September 2009, 07:52
Why is it only working with serout & serin2 combination. I tried it with serout+serin & serout2+serin2 but it didn't work in this combination.

Tray to introduce a pacing value in the SEROUT2 command. See page 140 PBP manual.

Al.

financecatalyst
- 1st October 2009, 00:54
Hi Everyone
I am now able to send text messeges. New Problem, I am unable to read an sent sms. Here is my code:
rea:
gosub one
serout2 tx,baud,["AT+CMGF=1",13]
Serin2 rx,baud,5000,rea,[WAIT("OK")]
pause 5000
gosub one
serout2 tx,baud,["AT+CMGR=1",13]
Serin2 rx,baud,5000,rea,[WAIT("REC UNREAD"),skip 3, STR num\12,skip 27,STR sms\10] 'CODE NEVER MOVES FORWARD FROM HERE
portc=255
pause 3000
portc=0
if sms[0]="t" and sms[1]="e" and sms[2]="s" and sms[3]="t" then
goto done
ELSE
goto rea
ENDIF


done:
serout2 tx,baud,["AT+CMGF=1",13]
Serin2 rx,baud,5000,main,[WAIT("OK")]
gosub two
gosub two
gosub two
serout2 tx,baud,["AT+CMGS=",34,"+44798XXXXXXXX",34,13]
Serin2 rx,baud,5000,main,[WAIT(">")]
PAUSE 500
SEROUT2 tx,baud,["done",26]
goto rea

sunsun
- 24th February 2011, 07:23
hi all,

I have read through the discussion that you guys had. They are so informative and useful. Now I want to send message to the PIC16f690 to turn on a LED. My GSM and PIC can work well with hyperterminal. However, if i want to have a direct connection from GSM to PIC, i dont get any response. Any ideas?

char AT[]={0x41,0x54,0x2B,0x43,0x4D,0x47,0x52,0x3D,0x34,0x0 D,0x0A}; //AT+CMGR=1

while(1)
{
for (j=0;j<11;j++)
{
TXREG=AT[j];
for (i=0;i<500;i++){
}
}

if (RCREG=='T') // if receive T then turn on LED
{
PORTC=0x01;
}
for (i=0;i<1000;i++){
}

}

mackrackit
- 24th February 2011, 08:44
I have read through the discussion that you guys had
And did you notice that we are using BASIC ?

sunsun
- 24th February 2011, 09:53
Yes I knew it. Though it's BASIC but I still get some ideas from it. So do you have any ideas for C?:)

financecatalyst
- 2nd December 2011, 07:49
After a long time, but I would like to ask here as well as you lot have worked with TC35i:

* Are there any AT commands for this or how to see the keyed in number from the mobile keypad on the other end during an active voice call. MY TC35i is connected to my comp with RS232. I am watching and sending normal AT commands using hyperterminal.

Currently what happens is that I dial the modem using my mobile, hyperterminal shows RING ****, I send ATA, and call gets answered and OK appears. After that when I press any number on the keypad, nothing appears on the hyperterminal.

Hope to crack this problem here soon. Thanks

aratti
- 2nd December 2011, 17:06
Numbers are encoded in the DTMF signal. If you need to read them you have to decode the dtmf sound signal. The easiest way is to use a MT8880.

Cheers

Al.

financecatalyst
- 2nd December 2011, 17:36
Thanks Al. Though I will search on this IC now, but I am a little confused as to the connections of this IC. What I mean is I have used TX/RX lines from RS232 already, where would this DTMF IN/OUT will connect to? I have come across few circuits but this IC is connected to home phone line rather than MODEMS.

aratti
- 3rd December 2011, 13:55
The DTFNM input that normally is connected to the phone line, must be connected to the voice out of your TC35i. Generally one capacitor of 100 nF and 100 Khoms in series is just enough. See the examples on the data sheet. The decoding is presented as a nibble ( 4 bits).

Cheers

Al.

Demon
- 22nd January 2012, 04:01
Moved from Schematics.

Robert