PDA

View Full Version : Problem displaying data from GPS module & using 16f877a



financecatalyst
- 22nd October 2009, 17:25
Hi, I am having problem showing data on hyperterminal using my GPS module and 16F877A
GPS module EM406A DEFAULT TO BAUD 4800
GPS is working as I connected it to PC without uC and I am getting the data. Problem is displaying it using PIC

Connections are as follow -:

PortC.4 ----Gps Tx (TTL 0-5V)
PortC.6 ----- MAx232 pin11
Max232 pin14 ----- Rs232 pin 2 (Pc Rx)
Gnd common

FOLLOWING IS THE CODE:
All pins digital, comparator off, analog channels off.

sms var byte[35]
Include "modedefs.bas"
DEFINE DEBUG_REG PORTC
DEFINE DEBUG_BIT 6
DEFINE DEBUG_BAUD 4800
DEFINE DEBUG_MODE 0

ab:
HIGH RED
serin2 portc.4,4800,[WAIT("$GPRMC"),STR sms\35]
DEBUG STR sms\17,13
pause 3000
LOW RED
goto ab

Is somthing wrong with the code or the hardware? Thanks

dhouston
- 22nd October 2009, 17:53
If the GPS works connected to a PC, it means its output is inverted.

You need to modify your
serin2 portc.4,4800,[WAIT("$GPRMC"),STR sms\35]Reread the manual for SerIn2 - your mode value is incorrect.

financecatalyst
- 22nd October 2009, 21:57
If the GPS works connected to a PC, it means its output is inverted.

You need to modify your
serin2 portc.4,4800,[WAIT("$GPRMC"),STR sms\35]Reread the manual for SerIn2 - your mode value is incorrect.

Thanks for the input but could you help me advising what baud should I use, I am little confused about this. The datasheet of the module does says 4800 is default (Datasheet attached) and manual also has only one option for 4800 baud.

I also want to say that I connected the gps module via MAX232 to the PC.Thanks

mackrackit
- 22nd October 2009, 22:37
I always wondered why the manual does not list all of the modes??? Save some paper???
http://www.melabs.com/resources/ser2modes.htm

financecatalyst
- 22nd October 2009, 23:10
Thanks for the info. I added the statement:
baud1 con 16572
and changed the following statement:
serin2 portc.4,baud1,[WAIT("$GPRMC"),STR sms\35]

Still no luck. Please help.

aratti
- 23rd October 2009, 01:21
serin2 portc.4,baud1,[WAIT("$GPRMC"),STR sms\35]

Which is the value of baud1?

When you use wait string, remember that they are case sensitive "$GPRMC" is different from "$gprmc"

I already suggested you, in another thread, to use a timeout sequence. Your serin2 instruction will wait for the identifier and then it will wait for a string of 35 characters. If your GPRS will send only 34, serin2 will remain there waiting forever.

One turn around is the use of the timeout:




GPRSLoop:
sms[0]=0
serin2 portc.4,baud1,500,GPRSTest,[WAIT("$GPRMC"),STR sms\35]
GPRSTest:
If sms[0]<>0 then goto label ?? ' here you check byte[0] for data presence
goto GPRSLoop


Al.

mackrackit
- 23rd October 2009, 05:40
Thanks for the info. I added the statement:
baud1 con 16572
and changed the following statement:
serin2 portc.4,baud1,[WAIT("$GPRMC"),STR sms\35]

Still no luck. Please help.
If a RS232 chip was needed to talk to a PC then baud1 should be 188.

financecatalyst
- 23rd October 2009, 16:58
Thanks guys. Itīs up and running now. Love this Forum

mackrackit
- 23rd October 2009, 17:53
Thanks guys. Itīs up and running now. Love this Forum
In case someone else has a similar problem... What was the fix?

financecatalyst
- 23rd October 2009, 18:37
In case someone else has a similar problem... What was the fix?

The array was too small to hold the sequence of characters and code was kinda stuck there. I changed it to the following :

Baud con 188
sms var byte[65]
start:
serin2 portc.4,baud,500,start,[WAIT("$GPRMC"),STR sms\65\13] ' added 13 as well
If sms[0]<>0 then goto display
goto start

These are the only corrections I have done and it fired up.

sradayda
- 15th April 2010, 10:27
Could u please provide the full program ?