Shop OBEX P1 Docs P2 Docs Learn Events
Need help with SERIN command — Parallax Forums

Need help with SERIN command

guitar_plrguitar_plr Posts: 31
edited 2005-01-24 12:28 in BASIC Stamp
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.

Comments

  • JonbJonb Posts: 146
    edited 2005-01-23 03:09
    www.picbasic.co.uk/support/Garmin.bs2 has some code that might interest you.

    serin GPS_Pin,N4800,2000,no_data,[noparse][[/noparse]wait("GPRMC,"), 
    str time\6,skip 1,status,skip 1,str latA\4,skip 1, 
    strlatB\2,skip 4,str lonA\5,skip 1,strlonB\2,skip 4,str 
    Spd\3,skip 3,str Cse\3]
    

    Worth a shot

    Jon
  • guitar_plrguitar_plr Posts: 31
    edited 2005-01-23 03:15
    Thank you for the response, 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!
  • ForrestForrest Posts: 1,341
    edited 2005-01-23 04:43
    In addition to the Nuts and Volts #103 - check out Jon Williams Easy_GPS.BS2 program midway down this forum page. Note you'll need to set your Garmin GPS to Garmin Text mode (and not NMEA)

    http://forums.parallax.com/showthread.php?p=517778
  • JonbJonb Posts: 146
    edited 2005-01-23 09:35
    I'm using that method to parse Sony format gps data from a UV40 module. The module has NMEA output but this format can be output every second.

    SONY10 9508211122322 N3833744 W12244456 +2345 234 271 9508211122321 A 3 A RHECT SHQFN BDdFP aGfFM KCJCN dCNFN CcPAB LfEAB P 2 34 O
    
    



    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
  • achilles03achilles03 Posts: 247
    edited 2005-01-23 14:21
    guitar_plr,
    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
  • guitar_plrguitar_plr Posts: 31
    edited 2005-01-23 16:24
    Thank you everyone for the replies!· I don't really NEED all that gps data, but I was just curious if I could capture the entire string.· Originally I had planned of getting the entire string and storing it in a variable, then passing it to a seperate procedure for parsing and picking out the specific data I wanted.· I thought that would be cleaner than parsing everything "in-line" while recieving the serial stream.·

    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_bsteve_b Posts: 1,563
    edited 2005-01-24 00:48
    Hey achilles...do you have to call in for a NOTAM or some FAA version of a "hey, I'm launching something way up high" notice!?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·

    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."
  • achilles03achilles03 Posts: 247
    edited 2005-01-24 12:28
    steve_b said...
    Hey achilles...do you have to call in for a NOTAM or some FAA version of a "hey, I'm launching something way up high" notice!?

    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
Sign In or Register to comment.