Need help with SERIN command
guitar_plr
Posts: 31
I am working on a project interfacing my GPS with the STAMP.· I have successfully connected them and am able to print the serial data to the debug window.· Problem is that since I can only declare a variable to have a maximum of 25 bytes before running out of space, the entire string (around 120 bytes) cannot be displayed. (reliably)
The data looks like something like : $PMGNTRK,xxxx.xxx,N,yyyyy.yyy,W,zzzzz, ... etc.
1.· Is there a workaround of being able to store more than 25 bytes in a variable in order to capture the entire string without multiple SERIN commands?· I don't want to break up the string until i pass it to another procedure to parse and seperate the data.
2.· If not, is it possble to nest the SERIN command with the SEROUT command?
for example:
SEROUT FMBS2,Baud,[noparse][[/noparse]$55,B_Write,Addr_hi,Addr_lo,(SERIN 1, 17197,[noparse][[/noparse]STR SerData 120])]
In order to dump the data from the GPS onto my RAMPack B?
Here is some of my code:
SerData VAR Byte(25)
getGPS:
· SERIN 1, 17197,[noparse][[/noparse]STR SerData \25]
· DEBUG STR SerData , CR
· PAUSE 100
GOTO getGPS
END
By the way, I have looked at Jon's Nut's & Volts column for guidance already (11/03), but he is using the SPSTR command for scratch ram which isn't on my BS2.
Thank you.
The data looks like something like : $PMGNTRK,xxxx.xxx,N,yyyyy.yyy,W,zzzzz, ... etc.
1.· Is there a workaround of being able to store more than 25 bytes in a variable in order to capture the entire string without multiple SERIN commands?· I don't want to break up the string until i pass it to another procedure to parse and seperate the data.
2.· If not, is it possble to nest the SERIN command with the SEROUT command?
for example:
SEROUT FMBS2,Baud,[noparse][[/noparse]$55,B_Write,Addr_hi,Addr_lo,(SERIN 1, 17197,[noparse][[/noparse]STR SerData 120])]
In order to dump the data from the GPS onto my RAMPack B?
Here is some of my code:
SerData VAR Byte(25)
getGPS:
· SERIN 1, 17197,[noparse][[/noparse]STR SerData \25]
· DEBUG STR SerData , CR
· PAUSE 100
GOTO getGPS
END
By the way, I have looked at Jon's Nut's & Volts column for guidance already (11/03), but he is using the SPSTR command for scratch ram which isn't on my BS2.
Thank you.
Comments
Worth a shot
Jon
I wasn't aware that you could pick out specific parts of the serial stream and assign them to variables all in the same line.· It looks like this will give me much more control for parsing the string.· Still wondering why I am limited to 25 bytes of storage...seems a bit low, doesn't it?
Thanks!
http://forums.parallax.com/showthread.php?p=517778
Specifications for decoding it can be found here for anyone interested: http://happy.emu.id.au/neilp/gps/ipsformat2.htm
Post Edited (Jonb) : 1/23/2005 9:42:10 AM GMT
Unfortunately, I haven't found a way to store more than 26 (not 25) variables from the GPS input string on the BS2. The best advice I can offer is to tell you to rethink how much GPS data you really need. Do you REALLY need more than 26 variables from the GPS? The answer is probably "no".
First, you don't want anything from that header ($PMGNTRK), so you can do a WAIT("$PMGN"),SKIP 3 command or something to bypass all that. Secondly, do you really need to record what hemisphere you're in? Do you plan on this project moving more than, say, 500 miles? If not, you can drop the hundreds and tens of degrees (since you're not traveling that far).
For instance, on one of my high altitude balloon projects (which traveled over 35 miles as the crow flies, and went up to 92kft), I only "grab" 14 variables. That's not very many variables considering how far it went and the range involved. And that's enough to nail down the position within about 10m in all directions. 17 variables would give you 1m (although commercial GPS units really aren't that accurate anyway). And if you don't plan on having the project go over 10km in altitude, that's another variable you can drop. Here's a clip of the code I used:
GPSD1 VAR Byte (5) 'latitude info from GPS; dmm.mm
GPSD2 VAR Byte (5) 'longitude info from GPS; dmm.mm
GPSD3 VAR Byte (4) 'altitude info from GPS; xxxx0 (meters)
SERIN GPSDATA,N2400GPS,2000,NOGPS,[noparse][[/noparse]WAIT("@"),SKIP 14, STR GPSD1\5, SKIP 4, STR GPSD2\5, SKIP 6, STR GPSD3\4]
So you need to answer this question: What data do you really care about, and what will your project be doing?
Hope that helps,
Dave
I am new to the BS2 and microcontroller programming, but not to standard programming, so I guess I'm sort of "spolied" coming from working with Java and C++ everyday.· I guess I have to learn to work within the limitations of this architecture.
Thanks again for the help!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·
Steve
http://members.rogers.com/steve.brady
"Inside each and every one of us is our one, true authentic swing. Something we was born with. Something that's ours and ours alone. Something that can't be learned... something that's got to be remembered."
Yeah, I'm not sure it's required, but most people call in a NOTAM telling them when to activate it and how long it'd last... Balloons really aren't a big "hazard" since you can see them over a mile away, and you're only supposted to launch them in VFR conditions.
Dave