View previous topic :: View next topic |
Author |
Message |
berlin vince joe V S
Joined: 26 Jun 2015 Posts: 16
|
Interfacing pic16f877a with sim900a |
Posted: Tue Aug 30, 2016 1:42 am |
|
|
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](images/smiles/icon_confused.gif) _________________ Thanks |
|
![](templates/subSilver/images/spacer.gif) |
Gabriel
Joined: 03 Aug 2009 Posts: 1067 Location: Panama
|
|
Posted: Tue Aug 30, 2016 3:11 am |
|
|
There is a driver that does this exactly, for that PIC, on the library.
G. _________________ CCS PCM 5.078 & CCS PCH 5.093 |
|
![](templates/subSilver/images/spacer.gif) |
asmboy
Joined: 20 Nov 2007 Posts: 2128 Location: albany ny
|
|
Posted: Tue Aug 30, 2016 11:25 am |
|
|
standard warning here about likely virtuality of design ideas...
|
|
![](templates/subSilver/images/spacer.gif) |
temtronic
Joined: 01 Jul 2010 Posts: 9174 Location: Greensville,Ontario
|
|
Posted: Tue Aug 30, 2016 7:36 pm |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
berlin vince joe V S
Joined: 26 Jun 2015 Posts: 16
|
Store the reply from gsm !!! |
Posted: Tue Aug 30, 2016 10:50 pm |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
ezflyr
Joined: 25 Oct 2010 Posts: 1019 Location: Tewksbury, MA
|
|
Posted: Wed Aug 31, 2016 10:23 am |
|
|
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! |
|
![](templates/subSilver/images/spacer.gif) |
berlin vince joe V S
Joined: 26 Jun 2015 Posts: 16
|
confusion on GET_SMS_COMMAND() |
Posted: Mon Jan 02, 2017 1:31 am |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19369
|
|
Posted: Mon Jan 02, 2017 3:30 am |
|
|
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.
|
|
|
![](templates/subSilver/images/spacer.gif) |
temtronic
Joined: 01 Jul 2010 Posts: 9174 Location: Greensville,Ontario
|
|
Posted: Mon Jan 02, 2017 6:04 am |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19369
|
|
Posted: Mon Jan 02, 2017 9:11 am |
|
|
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!... |
|
![](templates/subSilver/images/spacer.gif) |
benoitstjean
Joined: 30 Oct 2007 Posts: 553 Location: Ottawa, Ontario, Canada
|
|
Posted: Mon Jan 02, 2017 11:51 am |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
temtronic
Joined: 01 Jul 2010 Posts: 9174 Location: Greensville,Ontario
|
|
Posted: Mon Jan 02, 2017 2:39 pm |
|
|
following Ben's 'logic analyzer' theme.. for simple RS232 serial communications, a terminal program like Realterm works fine and it's free !
Jay |
|
![](templates/subSilver/images/spacer.gif) |
benoitstjean
Joined: 30 Oct 2007 Posts: 553 Location: Ottawa, Ontario, Canada
|
|
Posted: Tue Jan 03, 2017 5:38 am |
|
|
For the price, you can't go wrong. I can no longer work without a logic analyzer, it is just too useful. |
|
![](templates/subSilver/images/spacer.gif) |
ezflyr
Joined: 25 Oct 2010 Posts: 1019 Location: Tewksbury, MA
|
|
Posted: Tue Jan 03, 2017 9:31 am |
|
|
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
John _________________ John
If it's worth doing, it's worth doing in real hardware! |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19369
|
|
Posted: Tue Jan 03, 2017 1:33 pm |
|
|
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. |
|
![](templates/subSilver/images/spacer.gif) |
|