View previous topic :: View next topic |
Author |
Message |
tiryaka
Joined: 01 May 2007 Posts: 8
|
Sagem Mobile + PIC16F877 |
Posted: Tue May 01, 2007 11:58 am |
|
|
Hi,
I read several topics related to similar subject but I dont interstand where is my mistake.
I am making interface between a PIC16F877 and a Sagem Mobile (My X2) via MAX232, to send sms
The Sagem data cable I used has a DB9 connecteur and contain only 3 wire. RX,TX and GND.
http://img78.imageshack.us/img78/7434/db9yj9.th.jpg
Here is the programme I wrote.
#include <16F877.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)
void main() {
printf("AT\n\r");
delay_ms(2000);
printf("ATD+3333\n\r");
}
When I connecte the interface with the PC, The windows Hyperterminal receive both : AT and ATD+3333
but with the Sagem Mobile it doesn't dial.
Last edited by tiryaka on Tue May 08, 2007 11:51 am; edited 2 times in total |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue May 01, 2007 1:25 pm |
|
|
1. First get the Sagem unit working with your PC.
2. Then, make your PIC "look like" the PC, in terms of both the hardware
connections and the AT commands. |
|
|
Guest
|
|
Posted: Wed May 02, 2007 3:08 am |
|
|
Possibly a timing issue, it's normal to wait for (and test for) the response from the unit. You send 'AT' then 'ATD...' with no delay or test that the command has been accepted. It may be that the unit is not responding at all (hardware, baud rate etc) or that it will not accept your 'ATD...' because it's still responding to your 'AT' comand.
Do as PCM programmer suggests and try sending the commands slowly from the PC as you type them, then when that works, try sending them immediatly by storing a text file & sending the whole thing. |
|
|
tiryaka
Joined: 01 May 2007 Posts: 8
|
|
Posted: Wed May 02, 2007 3:29 am |
|
|
thank your for responding.
In the original program I used I have put a "delay_ms(2000)" between the two instructions (printf),but the result is nothing.
With the PC all the AT command work fine, and when I send atd+333 the Sagem Unit dial normaly.
Also when I connect the pic16F877 to the PC via the max232 and use the previous program ,the hyeprterminal receive correctly both AT and ATD+3333.
I have no problem with the comunication between the PC and the Sagem unit with at command.
Also I have no probleme with the communication between the Pic16f877 and the pc.
The probleme is between PIC16F877 and the Sagem Unit.
I used the data cable which have 3 wire,
I thing that I dont need a cts/rts or a xon/xoff flow control with a mobile,and its necessary only with slow devices as some printers.
I am wrong??? |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Wed May 02, 2007 4:06 am |
|
|
Quote: | I thing that I dont need a cts/rts or a xon/xoff flow control with a mobile,and its necessary only with slow devices as some printers. | Implementing some kind of flow control is always better but when sending and receiving short commands you often can get away without it. Often the modem has a (small) input buffer for storing incomming commands. You have to implement a similar buffer in your PIC so while processing a reply from the modem you can still receive new data in the background (this requires an interrupt on the RS232 receive, see ex_sisr.c for an example).
For the communication problem to the modem, are you sure your cable is correct? Maybe you need a cross cable (switch Rx and Tx). |
|
|
tiryaka
Joined: 01 May 2007 Posts: 8
|
|
Posted: Thu May 03, 2007 5:24 am |
|
|
yes ,I inverted tx and rx ,that's not the problem.
Is there any person who had made a similar project with a pic and a mobile???
I need help
I need juste to make the mobile dial with the pic, just the begining,after that i can continue without any problem.
Thank you for responding |
|
|
jaime
Joined: 25 Nov 2005 Posts: 56 Location: Porto - Portugal
|
|
|
tiryaka
Joined: 01 May 2007 Posts: 8
|
|
Posted: Sat May 05, 2007 7:45 am |
|
|
It's very good project,so you have used only three wire and no flow control.
I have also a Siemens A70 and it's data cable, I try AT command with Hperterminal but it doesn't work.
I think that A70 like A55 has no Built-in data and fax modem
http://www.mphone.co.uk/siemens/a55.html
Does it work with Siemens C45 without any Driver or configuration??? |
|
|
jaime
Joined: 25 Nov 2005 Posts: 56 Location: Porto - Portugal
|
|
Posted: Sat May 05, 2007 9:55 am |
|
|
hello
it works with a C45 and a ME45. You only need to connect a mobile to the system and put in the SIM memory the number that you want to turn on the system..
with hyperterminal you dont need any drivers
jaime _________________ www.jagsilva.com |
|
|
tiryaka
Joined: 01 May 2007 Posts: 8
|
|
Posted: Tue May 08, 2007 11:46 am |
|
|
Now I am working with a Siemens C55 and it works very well with hyperteminal.
http://img520.imageshack.us/my.php?image=picmobilcm3.jpg
So the pic16F877 send to both the PC and the Siemens C55,the terminal on the Pc recieve ATD+888 so normaly the phone Dial but it doesn't do it.
(reception ok) PC <-------- pic16F877 --------> Siemens C55 (no dialing?.?why??)
http://img490.imageshack.us/my.php?image=terminalnj7.jpg
Rx and Tx are correct.,I tryed 2400,9600,19200 but it's the same problem,the PC recieve but the cell phone do nothing.
Where is the mistake???? |
|
|
jaime
Joined: 25 Nov 2005 Posts: 56 Location: Porto - Portugal
|
|
Posted: Wed May 09, 2007 3:19 am |
|
|
Hello
-Did you try the mobile with the hyperterminal? it works?
-The cable you are using is a RS232 cable? When you connect pc and mobile in the same uart i cannot tell you that it woks... Connect only the pc and then only the mobile... TX and RX are really correct?
- can i see the test program?
thanks
Jaime _________________ www.jagsilva.com |
|
|
tiryaka
Joined: 01 May 2007 Posts: 8
|
SIEMENS C55 PIC16F877 |
Posted: Wed May 09, 2007 12:20 pm |
|
|
Hello
Yes I did it, the mobile Siemens C55 work very well with the terminal.
Yes the cable is an original one, it is an RS232 cable.
I tried the PIC16F877 with only the mobile, nothing
I tried the PIC16F877 with only the PC with terminal , work fine.
TX of PIC16F877 --------------> PIN 3 of rs232 Cable of the Mobile
RX of PIC16F877 --------------> PIN 2 of rs232 Cable of the Mobile
I tried also to invert but nothing.
The program
Code: | #include <16F877.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=20000000)
#use rs232(baud=19200, xmit=PIN_C6, rcv=PIN_C7)
void main() {
printf("AT\n\r");
delay_ms(2000);
printf("ATD+888\n\r");
} |
I have seen your project you didn't used an RS232 cable but directly from the PIC with a 3.3V zener diode. it's the same.
I think the problem is with the program.
Siemens mobile work with any speed????????????,I used 19200.
I have read your program,and that what I have not understand
Code: | else if(time_count>=100) //if no answer repeat command
{ //try 3 times and if still no answer
command_send=false; // changes baud rate
disable_interrupts(int_timer1);
fault++;
if(fault==3)
set_uart_speed(9600);
else if(fault==6)
set_uart_speed(14400);
else if(fault==9)
set_uart_speed(28800);
else if(fault==9)
set_uart_speed(38400);
else if(fault==12)
set_uart_speed(56000);
else if(fault==15)
set_uart_speed(57600);
else if(fault==18)
set_uart_speed(115200);
else if(fault==21) //If still no answer (21 times after)
{ //start blink all the leds and stop system |
Thank you jaime. |
|
|
jaime
Joined: 25 Nov 2005 Posts: 56 Location: Porto - Portugal
|
|
Posted: Wed May 09, 2007 3:40 pm |
|
|
It looks like its ok.
TX PIC PIN 26 ---> RX SIEMENS PIN3
RX PIC PIN 25 <--- TX SIEMENS PIN2
Try this... whithout \n...
Code: |
void main()
{
printf("AT\r");
delay_ms(2000);
printf("ATD+123456789;\r");
while(1);
} |
Jaime _________________ www.jagsilva.com |
|
|
jaime
Joined: 25 Nov 2005 Posts: 56 Location: Porto - Portugal
|
|
Posted: Wed May 09, 2007 3:42 pm |
|
|
And about my program...
Quote: | Code: | else if(time_count>=100) //if no answer repeat command
{ //try 3 times and if still no answer
command_send=false; // changes baud rate
disable_interrupts(int_timer1);
fault++;
if(fault==3)
set_uart_speed(9600);
else if(fault==6)
set_uart_speed(14400);
else if(fault==9)
set_uart_speed(28800);
else if(fault==9)
set_uart_speed(38400);
else if(fault==12)
set_uart_speed(56000);
else if(fault==15)
set_uart_speed(57600);
else if(fault==18)
set_uart_speed(115200);
else if(fault==21) //If still no answer (21 times after)
{ //start blink all the leds and stop system |
|
Siemens ME45 have auto baud rate. and works at different speeds...
Siemens C45 only works at 19200...
this was the solution i found to the "problem".
The PIC trys to connect at 9600 and if the mobile dont respond for trys it changes the baud rate and trys again...
i'm not a good programmmer...
Jaime _________________ www.jagsilva.com |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Wed May 09, 2007 4:28 pm |
|
|
Just a small note on a bug: Code: | else if(fault==9)
set_uart_speed(28800);
else if(fault==9)
set_uart_speed(38400);
| You are testing fault==9 twice, this results in your autobaud routine never transmitting at 38400 baud. |
|
|
|