CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Problem interface GSM TC35 with PIC18f4550
Goto page 1, 2, 3, 4  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
low



Joined: 04 Feb 2014
Posts: 28
Location: Malaysia

View user's profile Send private message AIM Address

Problem interface GSM TC35 with PIC18f4550
PostPosted: Tue Feb 04, 2014 2:15 am     Reply with quote

Hi,

I'm newbie for the CCS code. Can anyone help me see where my coding had wrong? It unable sms to handphone

Code:
#include <18F4550.h>                   // PIC18F4550 HEADER FILE
#include <stdlib.h>
#fuses HS,NOWDT,NOLVP,NOPROTECT        // EXTERNAL CLOCK, NO WATCH DOG TIMER, NO LOW VOLTAGE PROGRAMMING
#use delay (clock=20M)                 // 20 MHZ CRYSTAL
#include <lcd.c>                       // LCD DISPLAY HEADER FILE
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, stream=GSM)

////////////////////////////////////////////////////////////////////////////////
//                                                                            //
//                            I/O DECLARATION                                 //   
//                                                                            //
////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////
//                                                                            //
//                                  Output :LED                               //
//                                                                            //
////////////////////////////////////////////////////////////////////////////////

#define LED1         PIN_B6               // BUZZER 1
#define BUZZER       PIN_B7               // LED 2   
 


////////////////////////////////////////////////////////////////////////////////                                                               
//                                                                            //
//                               Input : SWITCH                               //
//                                                                            //
////////////////////////////////////////////////////////////////////////////////

#define BUTTON1        PIN_B0               // PRESET BUTTON 1 




////////////////////////////////////////////////////////////////////////////////
//                                                                            //
//                            LCD DISPLAY                                     //
//                                                                            //
////////////////////////////////////////////////////////////////////////////////


#define LCD_E           PIN_D0               // PIN E
#define LCD_RS          PIN_D1               // PIN RS
#define LCD_RW          PIN_D2               // PIN RW
#define LCD_D4          PIN_D4               // PIN D4
#define LCD_D5          PIN_D5               // PIN D5
#define LCD_D6          PIN_D6               // PIN D6
#define LCD_D7          PIN_D7               // PIN D7

////////////////////////////////////////////////////////////////////////////////
 




void main()
{

////////////////////////////////////////////////////////////////////////////////
//                                                                            //
//                              LOCAL VARIABLE                                //
//                                                                            //
////////////////////////////////////////////////////////////////////////////////

//int blinking;                       // VARIABLE FOR BLINK

////////////////////////////////////////////////////////////////////////////////
//                                                                            //
//                               PORT INITIALIZE                              //
//                                                                            //     
////////////////////////////////////////////////////////////////////////////////


lcd_init();                      //INITIALISE LCD



                   



////////////////////////////////////////////////////////////////////////////////
//                                                                            //
//                                 MAIN PROGRAM                               //   
//                                                                            //
////////////////////////////////////////////////////////////////////////////////
lcd_putc("\f....WELCOME.....");
delay_ms(1000);
lcd_putc("\f");
lcd_putc("\n...loading...!");
delay_ms(1000);
lcd_putc("\f");
lcd_putc("\f....Ready");
delay_ms(1000);



while(TRUE)                      // always repeat program

{
printf(lcd_putc,"\fSystem On");        // DISPLAY VR VALUE AT LCD DISPLAy
delay_ms(5);
if (!input(BUTTON1))             // when press button 1
{
output_high(LED1);               // turn on LED1
output_high(BUZZER);             // turn on BUZZER
lcd_putc("\f");
lcd_gotoxy(5,1);
lcd_putc("PIR DETECTED");
lcd_gotoxy(5,2);
lcd_putc("ALARM ON");
delay_ms(1000);
lcd_putc("AT+CMGF=\"1\r");            // send command and cel #
delay_ms(1000);                           // Delay long enough for modem response
lcd_putc("AT+CMGS=\"0174366043\"\r");            // send command and cel #   
delay_ms(1000);                           // Delay long enough for modem response
lcd_putc("Alarm on!!!\n\r");         // Text to reply
putchar(0x1A);                           // send Ctrl-z
delay_ms(20); 
}

else
{
output_low(LED1);
output_low(BUZZER);
lcd_putc(0x01);

}

}
}


Pls help me Sad Sad Sad Sad


Thank you


Regards,
Low
Mike Walne



Joined: 19 Feb 2004
Posts: 1785
Location: Boston Spa UK

View user's profile Send private message

PostPosted: Tue Feb 04, 2014 2:42 am     Reply with quote

1) Tell us what does work.
2) Add ERRORS to #use RS232.
3) Safer to insert a delay before initialising LCD.
4) How are you testing for sms?
5) Have you tested RS232 talks to a PC?
6) Have you tried using PC to send sms via RS232?
7) Learn to use code button.

Mike
low



Joined: 04 Feb 2014
Posts: 28
Location: Malaysia

View user's profile Send private message AIM Address

PostPosted: Tue Feb 04, 2014 3:05 am     Reply with quote

I ardy try use the Hyperterminal using RS232 the GSm is work.
But after i connect using PIC the GSM don't to work
Sad
The coding no hv error after i compiled it... but the GSM unable to sms...
It is my coding missing some code??

Regards
low



Joined: 04 Feb 2014
Posts: 28
Location: Malaysia

View user's profile Send private message AIM Address

PostPosted: Tue Feb 04, 2014 3:12 am     Reply with quote

when i press the button the led was on... but i didnt receive any message from GSm???

Regards,
Ttelmah



Joined: 11 Mar 2010
Posts: 19513

View user's profile Send private message

PostPosted: Tue Feb 04, 2014 3:34 am     Reply with quote

You are sending all the commands to the LCD, not to the GSM.....
How is this ever going to work?.

The only thing you send to the GSM, is the single CTRL-Z character.
low



Joined: 04 Feb 2014
Posts: 28
Location: Malaysia

View user's profile Send private message AIM Address

PostPosted: Tue Feb 04, 2014 3:41 am     Reply with quote

hi Ttelmah,

Can u teach me how to code it? What shd i add??I'm newbie still on learning.... Thank you


Regards
Mike Walne



Joined: 19 Feb 2004
Posts: 1785
Location: Boston Spa UK

View user's profile Send private message

PostPosted: Tue Feb 04, 2014 5:55 am     Reply with quote

low wrote:
I ardy try use the Hyperterminal using RS232 the GSm is work.
But after i connect using PIC the GSM don't to work
Sad
The coding no hv error after i compiled it... but the GSM unable to sms...
It is my coding missing some code??

Regards

So does this mean you know what characters to send to the GSM?

Mike

Asking several questions at once was too difficult, so I'll keep them in ones.
low



Joined: 04 Feb 2014
Posts: 28
Location: Malaysia

View user's profile Send private message AIM Address

PostPosted: Tue Feb 04, 2014 6:04 am     Reply with quote

thx Mike Very Happy

Regards
Mike Walne



Joined: 19 Feb 2004
Posts: 1785
Location: Boston Spa UK

View user's profile Send private message

PostPosted: Tue Feb 04, 2014 7:08 am     Reply with quote

I assume you can correctly send from a PC to GSM.

I suggest you use a PC to look at what you are trying to send from PIC to GSM.

Mike
Gabriel



Joined: 03 Aug 2009
Posts: 1067
Location: Panama

View user's profile Send private message

PostPosted: Tue Feb 04, 2014 8:23 am     Reply with quote

Hi Low,

Are you working on real hardware?
Does your LCD work?
How is the GSM module connected to the PIC?

Once you have answered these questions we can continue to help.
This is a pointless exercise if you dont have working hardware.

If all of the above is OK, then you should be able to use this Driver:

http://www.ccsinfo.com/forum/viewtopic.php?t=50390

... by changing the PIC# and fuses for your chip.

Its a pretty verbose driver and it should tell you what is going on or where its stuck on the LCD. Basically, it will tell you if your hardware is not working.

once you get the driver working as is, we can help modify the driver to your specific needs...

99% of the work is done for you already.

help us help you.

G.
_________________
CCS PCM 5.078 & CCS PCH 5.093
ezflyr



Joined: 25 Oct 2010
Posts: 1019
Location: Tewksbury, MA

View user's profile Send private message

PostPosted: Tue Feb 04, 2014 8:29 am     Reply with quote

Hi,

You should post a link to the datasheet for your TC35. There are many 'flavors' of this module depending on the extra interface circuitry that is
(almost) always included. I assume that yours has an RS232 interface, and that you are connecting the TC35 to the PIC via a MAX232 type IC, right?

As Ttelmah has noted, you define a stream 'GSM', but never use it to send data to the TC35. You need to use 'fprintf' for this purpose. Before you
blast off trying to send SMS messages, why not try a simple test to see if the modem responds to a simple 'AT' request? the modem should respond
with 'OK' if everything is working!

Code:

fprintf(GSM, "AT\r");


As a 'quick and dirty' test, use fgetc() in a loop right after this call to send any received characters to your LCD. Do you get the correct response?

Good Luck!

John
low



Joined: 04 Feb 2014
Posts: 28
Location: Malaysia

View user's profile Send private message AIM Address

PostPosted: Tue Feb 04, 2014 9:48 am     Reply with quote

Hi Gabriel,

yap, i done it on real hardware....
My LCD is working
Connection:
PIC TX connect to GSM TX
PIC RX connect to GSM RX

[/img]https://www.facebook.com/photo.php?fbid=718803788153760&set=a.380195265347949.96272.100000724357835&type=1&theater
low



Joined: 04 Feb 2014
Posts: 28
Location: Malaysia

View user's profile Send private message AIM Address

PostPosted: Tue Feb 04, 2014 10:00 am     Reply with quote

Hi Gabriel,

U mean the sample code??? I try compile it.. it got many of errors???

Hi ezflyr,

My connection is directly to GSM didnt via a MAX232 type IC...
PIC TX connect to GSM TX
PIC RX connect to GSM RX

Regards,
ezflyr



Joined: 25 Oct 2010
Posts: 1019
Location: Tewksbury, MA

View user's profile Send private message

PostPosted: Tue Feb 04, 2014 10:19 am     Reply with quote

Hi Low,

Ummm, you undoubtedly have a hardware issue...... First, this is totally wrong:

Quote:

PIC TX connect to GSM TX
PIC RX connect to GSM RX


The GSM Tx must (ultimately) be connected to the PIC Rx, and the GSM Rx must (ultimately) be connected to the PIC Tx.

You did not post a datasheet for the TC35 as I requested, so it's really a huge waste of time to speculate about your potential hardware issues.
If you can't do that, this is my final post in this thread! You *probably* need a MAX232 IC between the PIC and the GSM modem, but that's
just a hunch based on past dealings with the TC35.

If you connected the GSM module to you PC using the same interface that you are now attempting to connect to your PIC, then your hardware
implementation is 100% wrong!

Have you done any research in the forum? This exact problem has already been solved multiple times, so you are really asking us to
do your work for you!

John
low



Joined: 04 Feb 2014
Posts: 28
Location: Malaysia

View user's profile Send private message AIM Address

PostPosted: Tue Feb 04, 2014 10:48 am     Reply with quote

Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page 1, 2, 3, 4  Next
Page 1 of 4

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group