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 Previous  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
temtronic



Joined: 01 Jul 2010
Posts: 9271
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Fri Apr 11, 2014 6:24 am     Reply with quote

CCS supplies a 'driver' called LCD.C and there is the 'flex_lcd.c' posted by PCM_Programmer( I think) in the 'code library'.
Either allow easy access to the generic LCD modules in 4 bit mode though I use the flex version as it's more 'flex'ible!

Just start with the 'Hello World' type test program to get familiar with using the driver and be sure to have a delay_ms(500) BEFORE the lcd_init() function. This will ensure the LCD module has had time to powerup and get 'organized' before the PIC accesses it.


hth
jay
ezflyr



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

View user's profile Send private message

PostPosted: Fri Apr 11, 2014 7:11 am     Reply with quote

Hi low,

Where have you been for the past two months Laughing ?

Have you seen this thread: http://www.ccsinfo.com/forum/viewtopic.php?t=50390 ???

In that thread, Gabriel basically serves up exactly what you want to do on a silver platter. The only difference is that his example program is looking for specific SMS message content, and then writing to an LCD, but the modifications to do what you require would be minimal...... In short, you've got a solution that is 95+% of the way to your final goal, so your comment about not "getting the point to start" is quite baffling.....!!!

John
low



Joined: 04 Feb 2014
Posts: 28
Location: Malaysia

View user's profile Send private message AIM Address

PostPosted: Fri Apr 11, 2014 7:38 am     Reply with quote

hi ezflyr,

I reviewed for suitable ultrasonic sensor and sound sensor for my project. My project combination with three types of sensors and it able to send the message.Now left the final stage which gsm receive the message and trigger the pic off the alarm....

Thank you! I will try it.... Very Happy


Best Regards
low



Joined: 04 Feb 2014
Posts: 28
Location: Malaysia

View user's profile Send private message AIM Address

PostPosted: Mon Apr 14, 2014 6:28 am     Reply with quote

Code:
   if(data[14]=='1')
   {
   fprintf(GSM,"AT+CMGR=\"1\"r\n");
   delay_ms(500);
   counter=0;
   for(i=0;i<90;i++)
      {
         if(data[i]==0x22)
         {
            counter++;
            if(counter==6) break;
         }
      }
      i=i+3;
      temp=i;
      while(data[i]>=' '&&data[i]<='~')
      lcd_putc(data[i++]);
      if(data[temp]=='0')
      {
      output_high(LED1);
      output_low(LED2);
      }
      else if(data[temp]=='2')
      {
      output_high(LED1);
      output_high(LED2);
      }
      for(i=89;i>0;i--) data[i]=' ';
      delay_ms(500);
     
      fprintf(GSM,"AT+CMGD=1\r\n");
      delay_ms(500);
      while(data[2]!='O'||data[3]!='K');
      for(i=89;i>0;i--) data[i] = ' ';
                delay_ms(500);
 
   }


But i still fail to receive the msg... Can help me check the coding? where i had did wrong??Crying or Very sad Crying or Very sad
The code condition:
1.)Read the first msg [/b]AT+CMGR=1
2.)If the content msg=[/b]0
LED1 ON
LED2 OFF
If the content msg=2
LED1 ON
LED2 ON
pls help me.....10sss


Regards
Ttelmah



Joined: 11 Mar 2010
Posts: 19591

View user's profile Send private message

PostPosted: Mon Apr 14, 2014 7:14 am     Reply with quote

Look carefully at where you do your escapes in what you send. You have one \ missing. It'll send

AT+CMGR="1"r
low



Joined: 04 Feb 2014
Posts: 28
Location: Malaysia

View user's profile Send private message AIM Address

PostPosted: Mon Apr 14, 2014 7:21 am     Reply with quote

Ttelmah wrote:
Look carefully at where you do your escapes in what you send. You have one \ missing. It'll send

AT+CMGR="1"r



mean the correct is AT+CMGR="1"r ??
Ttelmah



Joined: 11 Mar 2010
Posts: 19591

View user's profile Send private message

PostPosted: Mon Apr 14, 2014 8:16 am     Reply with quote

No. That is what you are sending.....
ezflyr



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

View user's profile Send private message

PostPosted: Mon Apr 14, 2014 9:44 am     Reply with quote

Hi low,

A more fundamental problem is that you appear to be doing your development work "in the blind". What I mean is that you are sending the modem a command, and then observing "it's not working", but you have no idea why? When I did my GSM modem development work, everything that I sent to the GSM modem, I also sent to my PC as a diagnostic test. This is easy to do with a spare I/O pin designated as a software serial port. The code is also exactly the same, just a different stream is specified. If you could actually see what the GSM modem is "seeing", then you would now immediately what the problem is. As it stands now, without this diagnostic ability, your task will be very arduous!

John
low



Joined: 04 Feb 2014
Posts: 28
Location: Malaysia

View user's profile Send private message AIM Address

PostPosted: Wed Apr 16, 2014 11:12 am     Reply with quote

hi,


I tried the Gabriel code but get the error :

Code:
while(!STRING_SEARCH(CMTI))


Quote:
Function used but not defined:... STRINGE_SEARCH SCR=3086


What it mean??

Regards
temtronic



Joined: 01 Jul 2010
Posts: 9271
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Wed Apr 16, 2014 11:18 am     Reply with quote

It means what it says... that your program is trying to use the function 'string_search()' BEFORE it has been defined..

Odds are you've 'cut and pasted' Gabriel's code into your code in the 'wrong' place...that's my hunch without seeing your entire program.

hth
jay
low



Joined: 04 Feb 2014
Posts: 28
Location: Malaysia

View user's profile Send private message AIM Address

PostPosted: Mon Apr 21, 2014 11:18 pm     Reply with quote

Hi master,

I used and edit some onGabriel code still fail to display the SMS on LCD. Crying or Very sad Crying or Very sad
It jz stop display at "WAITING FOR SMS".... When i send sms to the gsm, the gsm siren will sound '`ding~~~' it mean the gsm had received my sms... I tasted on hyperterminal when 'ding~~' is sound it the hyperterminal is show +CMTI "SM",1!!!Any wrong I had done on editing the code?

The code i have edited from sample program:
Original:
Code:
if(CHECK_COM())
if(SET_PDU())
if(SET_MEM())
if(SET_CNMI())


Edited:
Code:
if(!CHECK_COM())
if(!SET_PDU())
if(!SET_MEM())
if(!SET_CNMI())



Best regards
ezflyr



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

View user's profile Send private message

PostPosted: Wed Apr 23, 2014 8:56 am     Reply with quote

Hello low,

I'm not sure what else you've changed, but the *small* changes you've shown us have fundamentally altered the way Gabriel's code is intended to operate. For example, the statement

Code:

if(CHECK_COM())


basically says 'check communications with the GSM modem, and continue if communications are confirmed'. Your code

Code:

if(!CHECK_COM())


basically says 'check communications with the GSM modem, and continue if communications are NOT confirmed'.

The same pretty much goes for all the other changes you've made. IOW, you can't randomly change the 'sense' of the logic and expect it to work the same way.

The *basic* problem you seem to be having is that you don't appear to have successful two-way serial communications between your GSM modem and your PIC. Without this, you will continue to spin your wheels round and round.....

It is *known* that you can communicate between your PC and your GSM modem, correct?

Can you communicate between your PC and your PIC?? This thread is now so long and convoluted that I honestly forget if this is true or not?

Once you can communicate between the PIC and the PC, then use the PC to 'simulate' the GSM modem. Watch on the PC for the PIC to send the 'AT' command, and then respond with 'OK', and work your way thru the code step-by-step to get it working using the PC to simulate the GSM modem. Once you are confident that this works, you *should* be able to connect the GSM modem to the PIC and everything should now work as expected.

A couple of caveats: there are some communications 'timeouts' built into Gabriel's code, so you might need to adjust these while you are troubleshooting using the PC, and be very careful when you connect the GSM modem to the PIC that the cable you use connects the 'TX' of the GSM MAX232 connection to the 'Rx' PIC MAX232 connection, and vice versa. In fact, this may be your entire problem at this point. Very easy to check with a continuity tester.

Good Luck!

John
Gabriel



Joined: 03 Aug 2009
Posts: 1067
Location: Panama

View user's profile Send private message

PostPosted: Wed Apr 23, 2014 9:17 am     Reply with quote

Hi guys,

Low, have you gotten the code to work exactly as it is posted?
its much easier for us to help you from a working starting point.

Have you tried your hardware and know for sure your LCD is working properly?

if you PIC is not communicating with the GSM module, the code AS IS will tell you its not getting any response.

if so, then you know you need to check your hardware.
Things to look for are proper line levels, if you need a MAX232 or not.

Most importantly (a mistake ive made myself a million times), make sure you have the TX of the pic on the RX of the GSM module.
This can get confusing some times since its not always clear who is the DTE on RS232 coms... try swaping the TX RX lines.

The other important thing is FLOW CONTROL.... if you can communicate with the PC to the GSM module, DISABLE FLOW CONTROL and save your settings.

Another thing, is Make sure you BAUD Rates are correct.

Make sure to not loose power on your GSM module when switching from PC to PIC in case it looses configuration with a power down.



G.
_________________
CCS PCM 5.078 & CCS PCH 5.093
Gabriel



Joined: 03 Aug 2009
Posts: 1067
Location: Panama

View user's profile Send private message

PostPosted: Wed Apr 23, 2014 9:19 am     Reply with quote

one more thing... your pic has several oscillator settings.
have you done a blink test to ensure its running at the right frequency?

if not your baud rate calculations will be messed up.

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: Wed Apr 23, 2014 9:47 am     Reply with quote

Hi Gabriel,

I reviewed a bit of the thread, and I believe that the PIC and LCD are working, and that the GSM modem is working with the PC. On the previous page, low posted this:

Quote:

The LCD still display COMMS FAILED RETRYING- STRUCK???


So, I believe that low has never successfully 'put it all together' and made the GSM modem and the PIC actually communicate. At this point I believe he's got a cabling problem (straight-thru vs null-modem, etc.) or something like that which is preventing the PIC and the GSM modem from talking to each other. As I said, about 2 minutes with a continuity tester will tell the whole story.....

John
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 Previous  1, 2, 3, 4  Next
Page 3 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