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

Interfacing pic16f877a with sim900a

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
berlin vince joe V S



Joined: 26 Jun 2015
Posts: 16

View user's profile Send private message

Interfacing pic16f877a with sim900a
PostPosted: Tue Aug 30, 2016 1:42 am     Reply with quote

Hi,

Currently i am trying to interface gsm modem sim900a with pic16f877a. Now i can successfully give AT commands through rs232. My primary need is to verify the received message and give appropriate control signal to the relay.
Any idea how can i store the received message in a variable i am already tried getc,fgetc

Any idea how can i do this Confused
_________________
Thanks
Gabriel



Joined: 03 Aug 2009
Posts: 1067
Location: Panama

View user's profile Send private message

PostPosted: Tue Aug 30, 2016 3:11 am     Reply with quote

There is a driver that does this exactly, for that PIC, on the library.

G.
_________________
CCS PCM 5.078 & CCS PCH 5.093
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

PostPosted: Tue Aug 30, 2016 11:25 am     Reply with quote

standard warning here about likely virtuality of design ideas...

Quote:
16F877a
temtronic



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

View user's profile Send private message

PostPosted: Tue Aug 30, 2016 7:36 pm     Reply with quote

Well without correct hardware the driver will fail ! That's a 5 volt PIC and a 3 volt perhipheral apprently with an RS232 (+-12V) interface ?
Something will go 'poof'......and the 'magic smoke' will come out.

Before you ask 'howe to make it work' confirm the ACTUAL hardware you have.

Jay
berlin vince joe V S



Joined: 26 Jun 2015
Posts: 16

View user's profile Send private message

Store the reply from gsm !!!
PostPosted: Tue Aug 30, 2016 10:50 pm     Reply with quote

how can i store the reply from gsm module ?

for ex:
When we send AT the gsm reply with OK and i need to store that OK in a variable. How that happens ? !!!!!
_________________
Thanks
ezflyr



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

View user's profile Send private message

PostPosted: Wed Aug 31, 2016 10:23 am     Reply with quote

Hi,

Seriously??? Did you even take a look to find the 'driver' that Gabriel mentioned can be found in the code library? He has offered up, on a silver platter, exactly what you want to do! Clearly, you didn't bother to look!

BTW, you should post your schematic! I'll bet a milkshake that your hardware interface between the SIM900 and the PIC is not correct!
_________________
John

If it's worth doing, it's worth doing in real hardware!
berlin vince joe V S



Joined: 26 Jun 2015
Posts: 16

View user's profile Send private message

confusion on GET_SMS_COMMAND()
PostPosted: Mon Jan 02, 2017 1:31 am     Reply with quote

hi,,
In this can you please give a clue what exactly this means
Code:

int GET_SMS_COMMAND()
{
   if(STRING_SEARCH(AIRE)==1)return(AIRE);    // Using string_search() goes through
   else                              // all user defined commands.

   if(STRING_SEARCH(LUZ1)==1)return(LUZ1);
   else

   if(STRING_SEARCH(LUZ2)==1)return(LUZ2);
   else
   return(0);                           // returns zero if nothing found
}

_________________
Thanks
Ttelmah



Joined: 11 Mar 2010
Posts: 19548

View user's profile Send private message

PostPosted: Mon Jan 02, 2017 3:30 am     Reply with quote

This is a question of looking at the code. You have 'search strings':

Code:

// It is _IMPERATIVE_ that these match the define statements at the top
//
//                                              (SEE DEFINES AT TOP)
const char Strings[TOTAL_STRINGS][SIZE_COMMAND]={   "OK\0",               // index 0
                                       "+CMTI\0",            // index 1
                                       "ERROR\0",            // index 2
                                       "Exitosa\0",         // index 3
                                       "Aire\0",            // index 4
                                       "Luz1\0",            // index 5
                                       "Luz2\0"};            // index 6

//and defines to go with these:
#DEFINE AIRE   4          // 5 <-- USER DEFINED
#DEFINE LUZ1    5          // 6 <-- USER DEFINED
#DEFINE LUZ2   6          // 7 <-- USER DEFINED


Now note it says 'user defined'. _You_ as the user of the code, can put in these strings the words you want to look for.

If you read the thread (and the original one for the older driver - hopefully you are using the later one), you find:
Quote:

As is, the sample program responds to 3 commands: "Luz1", "Luz2" & "Aire".
(spanish for Light1, Light2, and Airconditioning)
The only action taken by the code is to display a message on the LCD.
[/code]

So the 'LUZ1' means 'Light1', and if you send an SMS saying 'Luz1', the main code send this to the LCD.

All you need to do, is change the defined names to names for what you want to do, change the strings to ones that you want to send for these actions, and change the actions to be what you want to happen when these are received.

temtronic



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

View user's profile Send private message

PostPosted: Mon Jan 02, 2017 6:04 am     Reply with quote

from Mr T's post...
Code:
 if(STRING_SEARCH(LUZ1)==1)return(LUZ1);

IF 'LUZ1' IS found during the string_search THEN '5' will be returned to the calling program

Jay
Ttelmah



Joined: 11 Mar 2010
Posts: 19548

View user's profile Send private message

PostPosted: Mon Jan 02, 2017 9:11 am     Reply with quote

Just a slight 'beware' here.
The item name define is 'LUZ1', but the search string is 'Luz1'. The search is case significant, so easy to get caught out!...
benoitstjean



Joined: 30 Oct 2007
Posts: 566
Location: Ottawa, Ontario, Canada

View user's profile Send private message

PostPosted: Mon Jan 02, 2017 11:51 am     Reply with quote

First I suggest you understand how to store characters in a string. Then understand how to store incoming serial characters into a string. Once the string is complete, then process it.

BTW, most messages from the SIM modems start with 0x0D 0x0A and also end with 0x0D 0x0A. Therefore printing the string in a terminal will show a blank line before and after the readable response. So this said, you need to take this into consideration.

You should also be aware that there are inconsistencies in certain messages / responses from the SIMxxx modules.... And some messages respond with a +{response} followed by a colon and parameters, others +{response} followed by OK, others just an OK etc.

I strongly suggest you get yourself a logic analyzer to analyze the serial data because you might run into surprises.

But, first things first, understand how to manipulate a character string, how to parse a character string then how to receive serial charcters and store them into a string etc.

Good luck.

Ben
temtronic



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

View user's profile Send private message

PostPosted: Mon Jan 02, 2017 2:39 pm     Reply with quote

following Ben's 'logic analyzer' theme.. for simple RS232 serial communications, a terminal program like Realterm works fine and it's free !

Jay
benoitstjean



Joined: 30 Oct 2007
Posts: 566
Location: Ottawa, Ontario, Canada

View user's profile Send private message

PostPosted: Tue Jan 03, 2017 5:38 am     Reply with quote

For the price, you can't go wrong. I can no longer work without a logic analyzer, it is just too useful.
ezflyr



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

View user's profile Send private message

PostPosted: Tue Jan 03, 2017 9:31 am     Reply with quote

Hi,

I somewhat disagree about the focus that is being placed on the code at this point in time. All the understanding in the world about 'strings' is not going to be of any value in this project if the hardware configuration is not correct. All projects should start with a proper hardware design and go from there. Historically, at least on this forum, the hardware design for a GSM project is proven to be wrong in most of these projects. The OP should post his schematic so that we can help him to ensure his hardware design is correct. I asked him to do this back in August. I'm still waiting Laughing

John
_________________
John

If it's worth doing, it's worth doing in real hardware!
Ttelmah



Joined: 11 Mar 2010
Posts: 19548

View user's profile Send private message

PostPosted: Tue Jan 03, 2017 1:33 pm     Reply with quote

Agreed. Temtronic pointed this out early in the thread.
There are a huge range of potential problems.
First the actual signalling voltage from the chip, if trying to connect directly.
Then the power actually needed to drive the unit (the pulse currents from the module are very high when it calls).
Then general RF noise etc..
Innumerable others.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
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