View previous topic :: View next topic |
Author |
Message |
princejude
Joined: 07 Aug 2010 Posts: 72
|
Car tracker using GPS and GSM with one hardware USART chip |
Posted: Fri Apr 27, 2012 6:43 am |
|
|
Hello Everyone,
I want to build a mini project titled: GPS Car Tracker.
The project description is as follow:
This will be designed such that the device will be attach to a vehicle so that in case of car theft, the car owner will be able to send a coded SMS to the device attached to the car, and the device will instantly reply back with an SMS to give the user information about the car’s location in terms of Longitude and Latitude. The car owner can now look up these values in a map to get the location of his/her car at any point in time.
I have worked with some GPS and GSM modem separately without any problem.
Since the GPS module transmits data continuously, I wrote the GPS data extraction section of my code in main function and the GSM code in hardware USART (#int_rda) interrupt.
I was using PIC16F887 but when I combined the gps and gsm codes, the code was not compiling due to many variables in both gps and gsm codes
The error message was "Not Enough RAM for all variables".
After I switch to high chip (PIC18F4520), the code complied but the #int_rda was not working in my simulator(Proteus). I used an LED to monitor the serial interrupt, and the LED is not comming ON with 18F but is comming with 16F. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9243 Location: Greensville,Ontario
|
|
Posted: Fri Apr 27, 2012 7:03 am |
|
|
this...
was not working in my simulator(Proteus).
says it all..
get RID of Proteus !!
Real code in real PICs does WORK !!!
I won the 'coffee and donut' bet the other day,took about 50 minutes to cut the code.What was real impressive was the linkage to Google maps for the realtime tracking. Bloody scary what can be done with so few parts!!! |
|
|
princejude
Joined: 07 Aug 2010 Posts: 72
|
|
Posted: Fri Apr 27, 2012 9:59 am |
|
|
Temtronic said:
Quote: | get RID of Proteus !! |
Yes I have started the hardware test with my dev. kit. I just tested the GPS with hyperTerminal and the signals are ok.
I tried to extract the GPS cordinates to LCD on my kit and no success yet. I will debug it this weekend to check why the LCD is not seeing the cordinates.
My question is, Will it be possible to put the GPS code in main function using any PIC pin (using stream) to recceive the GPS signal and the GSM on the hardware USART pins (RC6 & RC7) using #int_rda interrupt to receive the sms.
Please if I am not doing it well, how will I do it. And if possible I will like to see some sample codes. I will post my code shortly. |
|
|
ezflyr
Joined: 25 Oct 2010 Posts: 1019 Location: Tewksbury, MA
|
|
Posted: Fri Apr 27, 2012 1:15 pm |
|
|
Hi princejude,
It's funny how two people can look at the same problem, and come to opposite conclusions...... If it were me, I'd connect the GPS (which generates a lot of data asynchronously) to the hardware UART, and the GSM module (which generates a modest amount of data at predictable times) to a software UART.
One trick you can use is to connect the TxD pin of the GSM module to the external interrupt pin on the PIC, and use the INT_EXT ISR for the GSM module data reception. It's un-buffered (unlike the hardware UART), but at least each incoming character will trip the interrupt.
Another solution would be to find a PIC with two hardware UARTs.
John |
|
|
princejude
Joined: 07 Aug 2010 Posts: 72
|
|
Posted: Mon Apr 30, 2012 5:53 am |
|
|
ezflyr wrote
Quote: | If it were me, I'd connect the GPS (which generates a lot of data asynchronously) to the hardware UART, and the GSM module (which generates a modest amount of data at predictable times) to a software UART. |
Thanks for this wonderful comment. I have connected the GPS to hardware UART and I can now extract the GPS data to LCD. I don't have the GSM modem now to test in hardware(I will get it in few weeks time). Maybe I will try to use hyperterminal to emulate the GSM modem before I get the real modem. |
|
|
ezflyr
Joined: 25 Oct 2010 Posts: 1019 Location: Tewksbury, MA
|
|
Posted: Mon Apr 30, 2012 7:44 am |
|
|
Hi,
I recently completed a project that uses a GSM module for remote power switching and telemetry. This is the GSM module I used: http://www.sparkfun.com/products/10138 and I can highly recommend it for ease of use, and excellent performance.
It's a 3.8v unit, so it helps to run your PIC at this voltage also unless you want to use level converters on all the I/O.
I also wrote a VB6 program to emulate the GSM module for use during the development of my firmware! That was a big help!
John |
|
|
princejude
Joined: 07 Aug 2010 Posts: 72
|
|
Posted: Mon Apr 30, 2012 8:23 am |
|
|
I have used wavecom and siemens GSM modems before without GPS. I used them in some mini projects like to ON and OFF some appliances using sms. I used them with hardware UART and also did NULL modem connection(Tx of GSM to Tx of PIC and RX of GSM to Rx of PIC) through level converter(max232) circuit.
Now that I am using software UART for the GSM, will the NULL modem connection work with the software UART. And if not, what will I do ? |
|
|
ezflyr
Joined: 25 Oct 2010 Posts: 1019 Location: Tewksbury, MA
|
|
Posted: Mon Apr 30, 2012 9:46 am |
|
|
Hi,
The electrical interface to the GSM modem will be the same regardless of whether you are using a hardware or software UART. There is a slight level sensitivity difference with the 'Rx' input on the PIC, but that won't be a factor if you use the MAX232.
Are the GSM modems you are using actually old cellphones? Do they have keypads, and displays, etc.? The module I posted is just the GSM engine, so it will fit inside a very compact package! This type of module can also be directly interfaced to your MCU without MAX232 IC's.
Did you see my suggestion to connect the GSM data input to the external interrupt on the PIC? This will give you a 'pseudo' 2nd hardware UART. Again, note there is no character buffering, so keep that in mind!
John |
|
|
princejude
Joined: 07 Aug 2010 Posts: 72
|
Siemens TC35 gsm modem |
Posted: Thu May 24, 2012 7:13 am |
|
|
I bought the gsm modem(SIEMENS TC35) but it was not working with my PIC. The TC35 modem works normal with hyperterminal but is not working with my PIC16f887. I don't know why.
My test code to send sms is below:
Code: | #include <16F887.h>
#device adc=8
#FUSES NOWDT //No Watch Dog Timer
#FUSES XT //High speed Osc (> 4mhz for PCM/PCH) (>10mhz for PCD)
#FUSES NOPUT //No Power Up Timer
#FUSES NOMCLR //Master Clear pin enabled
#FUSES NOPROTECT //Code not protected from reading
#FUSES NOCPD //No EE protection
#FUSES NOBROWNOUT //No brownout reset
#FUSES IESO //Internal External Switch Over mode enabled
#FUSES FCMEN //Fail-safe clock monitor enabled
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NODEBUG //No Debug mode for ICD
#FUSES NOWRT //Program memory not write protected
#FUSES BORV40 //Brownout reset at 4.0V
#use delay(clock=4000000)
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8,errors)
#define CZ 26
char* SendSmsCmd = "AT+CMGS=+2348030674883";
void Outgoing_sms(void)
{
printf("%s\n",SendSmsCmd);
delay_ms(100);
printf("Testing my gsm modem");
delay_ms(100);
printf("%c",CZ);
}
void main() //************************************
{
output_A(0x00);
delay_ms(50000);
output_high(PIN_A0);
Outgoing_sms();
output_high(PIN_A1);
while(true)
{
}
}
PLS why will this simple code not working with this TC35 and I have used it with other modem such as wavecom.
|
|
|
|
ezflyr
Joined: 25 Oct 2010 Posts: 1019 Location: Tewksbury, MA
|
|
Posted: Thu May 24, 2012 7:47 am |
|
|
Hi,
Are you absolutely sure that your PIC can communicate successfully with the GSM modem? Try sending a simple 'AT' command, and see if you get an 'OK' in return. This kind of a basic test is really mandatory before you go blasting off and try to start sending SMS messages.
I do note one pretty serious issue with your timing. See if this thread will help you: http://ccsinfo.com/forum/viewtopic.php?t=48274
Also, your test program is way too complicated. For a basic troubleshooting test, you should be keeping everything as simple a possible, ie. don't use pointers, don't be using subroutines needlessly, etc. Use the test program in the thread above to test your modem, and keep it simple until it works!!
Another thing is that the GSM modem needs to be powered up in a very specific way. A quick look at the documentation shows that input control signal *IGT must be held low for 100ms after powerup to activate the module. Are you doing that? Again, trying to send an SMS message is not the first thing I'd be trying to do until I was sure the modem was actually up and running!
John |
|
|
princejude
Joined: 07 Aug 2010 Posts: 72
|
|
Posted: Fri May 25, 2012 9:01 am |
|
|
Hi John,
I have tested this (TC35) in different ways (with different codes) and no communication with my PIC16F887. I don't know if there is any setup/enable command I have to send to this stupid TC35 modem before it can listen to my PIC mcu. Funny enough, my colleague used this same modem with AVR mcu and he succeeded in sending sms from the modem to his handset. But he has not succeeded in reading and extracting the content of sms from the modem to LCD. |
|
|
ezflyr
Joined: 25 Oct 2010 Posts: 1019 Location: Tewksbury, MA
|
|
Posted: Fri May 25, 2012 10:59 am |
|
|
Hi,
OK, you said it works with "Hyperterminal", so what's different? Are you sure the electrical interface (signal levels, polarity, GSM Tx -> PIC Rx, PIC Tx -> GSM Rx, etc) is OK?? Are you sure that you are 'enabling' the module as specified?
I can assure you that the TC35 modem is not stupid, you're just doing something incorrectly. It's all in the datasheet, but you've got to read and study it carefully. These types of projects do not lend themselves to the "dart board" approach (ie. throw a bunch of darts until you hit the bullseye), they require careful coding to adhere to the operating specifications of the device.
I may regret asking this, but can you post a schematic?
John |
|
|
Gabriel
Joined: 03 Aug 2009 Posts: 1067 Location: Panama
|
|
Posted: Fri May 25, 2012 12:31 pm |
|
|
check for hardware flow control... and disable it on the pc and on the Cell _________________ CCS PCM 5.078 & CCS PCH 5.093 |
|
|
princejude
Joined: 07 Aug 2010 Posts: 72
|
|
Posted: Mon May 28, 2012 10:14 am |
|
|
ezfly wrote:
Quote: | I may regret asking this, but can you post a schematic? |
My schematic is simple. I am testing the modem with a development kit (with 4MHz crystal). I connected the PIC MCU's Tx pin (PIN_C6) to TC35's Tx pin, MCU's Rx pin (PIN_C7) to to TC35's Rx pin and GND to GND. That is NULL MODEM connection.
Gabriel wrote:
Quote: | check for hardware flow control... and disable it on the pc and on the Cell |
How do I disable it on the PIC MCU? I thought hardware flow control is only used during serial testing using terminal windows such as hyperterminal ? |
|
|
ezflyr
Joined: 25 Oct 2010 Posts: 1019 Location: Tewksbury, MA
|
|
Posted: Tue May 29, 2012 6:36 am |
|
|
Princejude,
I asked to see a schematic because a diagram very often clears up any ambiguities that a verbal description often introduces......
It's not at all clear to me from your description whether you've got the TC35 module wired correctly to your PIC or not. I took a quick look at the TC35 datasheet, and these are the pin-to-pin connections that I came up with. Is this how you have it wired?
GSM ---- PIC
19 <---- 17
18 -----> 18
On the GSM modem, I'd connect pins 21 and 22 to ground thru two separate resistors. These connections will disable the handshaking on the modem.
You still haven't addressed my earlier comments about "Turning On the GSM modem". Most GSM modems have a very specific startup procedure, but you seem to be totally ignoring this issue?? Have you got a handle on that? It's all in the datasheet.
John |
|
|
|