Log in

View Full Version : polling information in rs-232



Tondunard
- 8th February 2008, 14:35
Hi all,

i'm new to your community and in search of a (probably) simple answer to my problem.

pardon my inexperience, but to learn i guess the best way is to start asking for help (after doing a big search everywhere; OF COURSE ).


my problem:

i have a strip of data from a gps unit in NMEA

$GPGGA,150126,4521.3660,N,07317.9876,W,1,03,102.3, ,,-032.30,M,,*1D

i use a 16f877a (to receive it's no problem)

the problem is that i want to re-send that information ($GPGGA, etc....) every second while i still watch the next incoming data.

here's a simple example:

' This will set the serial port 4800
DEFINE HSER_RCSTA 90h
DEFINE HSER_TXSTA 20h
DEFINE HSER_BAUD 4800
GPS VAR byte
char var byte


main:
' receive from GPS unit
Hserin [char] ' <- works!
GPS = GPS + char '<<<< that part is causing the problem >>>>
' send to computer
hserout [GPS]
goto main:

what i really want to achieve is that the part "hserout [char]" would transmit to the PC every second while i still check the incoming "Hserin [char]" from GPS unit

i know there might be a much simpler way to do this, so i need a bit of your experience please.

Tried to lower the baudrate, tried with interrupt, etc... the "GPS = GPS + char" cause some garble characters in the receiving process...
If i use a LOOP in the "hserout [GPS]" i prevent the reception of new data from GPS unit.

there might be a way while reading the RECREG , but i don't know how....


Awaiting your help

skimask
- 8th February 2008, 15:28
Are you trying to receive the whole string at one time and retransmit the same whole string at once?


GPS = GPS + char '<<<< that part is causing the problem >>>>

What is this line supposed to accomplish?

Tondunard
- 8th February 2008, 15:47
i guess i didn't expose my problem clearly as i can see

yes i want to transmit the whole line (si i need to store it in a variable in some way)


to tell the truth, i have this radio that has GPS capabilities but it has to be "polled" so as far i can say , it does not transmit every second (the radio that is),.
so the radio transmit it's position every time i "poll" it.

after that i need to take that information and resend it to a gps software every second (to simulate a directly connected GPS)

plus i need to check for incoming data while this second by second transmit to the pc is done.( next strip of NMEA)

i guess it's better explained that way

thanks for the concern, looks like a real good place to learn picbasic

skimask
- 8th February 2008, 16:08
i guess i didn't expose my problem clearly as i can see
yes i want to transmit the whole line (si i need to store it in a variable in some way)
to tell the truth, i have this radio that has GPS capabilities but it has to be "polled" so as far i can say , it does not transmit every second (the radio that is),.
so the radio transmit it's position every time i "poll" it.
after that i need to take that information and resend it to a gps software every second (to simulate a directly connected GPS)
plus i need to check for incoming data while this second by second transmit to the pc is done.( next strip of NMEA)
i guess it's better explained that way
thanks for the concern, looks like a real good place to learn picbasic

The holy GREEN MANUAL describes how to handle strings using HSERIN/HSEROUT quite well.
And you might even find a use for WAIT in there too.

Tondunard
- 8th February 2008, 16:45
The holy GREEN MANUAL describes how to handle strings using HSERIN/HSEROUT quite well.
And you might even find a use for WAIT in there too.

i'll check again (guess i haven't looked too well

Still searching.....

b1arrk5
- 9th February 2008, 00:42
As you already have the hardware uart connected to the GPS unit, I'll ask how do you have the PC connected? 4800 baud is standard for a GPS unit, so you're good there. Skimask has correctly suggested that you will find that PicBasic's Hserin command does let you accept an entire string at once, instead of reading in a single character at a time and building a string like you are trying to do. You'll have to declare an array variable big enough to accept all of the characters in your string.
I would use an interrupt to capture the incoming string from the GPS unit, and then either DEBUG or SEROUT to send the string out to the PC. There are a few serial interrupt example programs on the MicroEngineering Labs website, and there are a lot of examples on this forum, and debug and serout or serout2 are explained well in the manual.

Jerry.

skimask
- 9th February 2008, 06:21
I would use an interrupt to capture the incoming string from the GPS unit

HSERIN also lets you terminate inputting with a certain character when using the STR option, thereby eliminating interrupts.

Tondunard
- 9th February 2008, 17:07
thanks to all, it finally worked... (not as i have expected though)

what i wanted to achieve was to put all the characters in an array, but my programming skills are somehow limited for now (learning you know and HSERIN is tricky sometimes).

but i guess i'll get there eventually

i know it's a simple thing to do (for you guys or gals?) (noticed there's a Melanie with a lot of braincells around here) :)

i am not that bad in VB but going back a sequential way of programming is like (for me that is) going the other way around!

at 49 years old, i guess i am not that bad, just hope you all enlighten me of your knowledge somehow (but i don't want to be taken by the hand)

i am probably a NEWBIE in this pic programming but not a BEGGER who wants to have the job done by others!

So i guess i'll just keep on going on this little project of mine and thanks a lot again for the pointers.

i'll stick around. :) :)

Archangel
- 9th February 2008, 21:09
Hi Tondunard,
Welcome from a 52 year old noobie to any kind of programming, I have been hangin' out here for about 19 months now, it is fun to revisit my earlier forrays into PBP. The learning curve seems to have a few bumps in it, but this is the place to find the straight talk.
JS

Tondunard
- 9th February 2008, 21:14
Hi Tondunard,
Welcome from a 52 year old noobie to any kind of programming, I have been hangin' out here for about 19 months now, it is fun to revisit my earlier forrays into PBP. The learning curve seems to have a few bumps in it, but this is the place to find the straight talk.
JS

nice to meet you sir, hope i'll find some answers to all my questions (by searching this forum)

Later ;)

mackrackit
- 9th February 2008, 22:29
hope i'll find some answers to all my questions (by searching this forum)
Welcome to the forum. You got it. The way to learn is to try things and read this forum daily, not just when you have a problem. If time permits I like to work through some of the problems people have and see if I can figure them out. Just like a home work assignment.

Some of the professors here are even funny:)

Tondunard
- 10th February 2008, 13:10
Welcome to the forum. You got it. The way to learn is to try things and read this forum daily, not just when you have a problem. If time permits I like to work through some of the problems people have and see if I can figure them out. Just like a home work assignment.

Some of the professors here are even funny:)

That's just great, hope i'll be able to do that someday.

what i would like to achieve is to put a strip of data (60 characters) in a variable so that i can modify it later and resend-it every second.

Can't seem to be able to put my finger on it, but i am so close.

anyway, i'll search again (and again), and i will finally get it somehow ;)

what i have now is a hserin (to receive) and right after that a hserout.

Putting incoming serial data in a variable is like a big miracle (lol).

Timing is my big problem for now, while i receive (hserin) i don't have time to store the data somewhere (loosing characters)

so far i made some progress, i'll get there eventually...


Later

Alain

mackrackit
- 10th February 2008, 14:07
I have not tried what you are doing but this might help
http://www.picbasic.co.uk/forum/showthread.php?t=2130&highlight=long+strings

BrianT
- 10th February 2008, 19:40
Have a look at
http://www.picbasic.co.uk/forum/showthread.php?t=5423
where you will see an example of reading the NMEA data stream, putting the selected string into an array and extracting the wanted fields.

You will normally NOT want to retransmit the entire NMEA stream, but instead just selected fields.

HTH
Brian

Tondunard
- 12th February 2008, 12:32
Got more and more info, that's just great


i'll digest all that today


it's way cool here....

Alain