Shop OBEX P1 Docs P2 Docs Learn Events
Parsing 4800 bps GPS strings with BS2sx — Parallax Forums

Parsing 4800 bps GPS strings with BS2sx

ttessierttessier Posts: 14
edited 2006-06-16 12:10 in BASIC Stamp
Has anyone successfully read in serial strings at 4800 bps with a BS2sx or lower? Seems all the successes on the forum have been with BS2p's and higher. I'm trying to read in· GPS $GPGGA sentences for parsing, but can't seem to get the data to come in properly at all. I'm using one of the I/O ports with a 22K resistor in series with the RS232 GPS output.

Comments

  • ToideToide Posts: 6
    edited 2006-06-12 18:54
    I did both using a Pahros 360 GPS and a garming eTrex conected to a BS2 and a BS2sx.· It works just fine !
  • ttessierttessier Posts: 14
    edited 2006-06-12 19:31
    Thanks. I dug deeper and found that the PC interface is 9600 bps as it is, with hardware flow control. I'll try to set up this port with the GPS at 4800 bps and see how it goes. I wonder if I would bugger up the interface to the PC if I had it change speed, or does it default to the PC programmer speed prior to the program running?

    I haven't had success with an input port, maybe it's just noise in my setup. At any rate, I know the interface to the equivalent to the SIN/SOUT port on this OEM BS2sx works.
  • ToideToide Posts: 6
    edited 2006-06-12 19:37
    If you just set a basic SERIN instruction captuting the data in a string and then relay that to the Debug port you should be able to play with the parameters in the Debug screen. Or better jet, just conect the GPS directly to the PC and play with the parameters.· 4800 bauds is the standard
  • ttessierttessier Posts: 14
    edited 2006-06-13 00:35
    I am seeing an unexpected behaviour. For transmitting at text file to test the function at 1200 bps, it would only work without any·errors if I set·the connection·on the transmit·side to even parity. I set the port parameter to 18447, which should be (if I am correct) 1200 bps, inverted, no parity. I used 1 stop bit on the sending end as well; it uploads perfectly. Higher speeds won't work.

    Set it to no parity, and only the first character is correct, the rest are alternating correct/incorrect.·For example, six "m's" gives "m[noparse][[/noparse]m[noparse][[/noparse]".

    I'm using·a BS2sx in an OEM module, stock #27294. Now, the Sin and Sout lines worked fine, I can crank up the speed to 9600 bps using "debug" to a terminal, but if I set the output manually, it produces the errors again.

    Also, I can't get the output on pin 1 to respond...stays steady at 5V, while pin 0 on the input works. I'll try some other ports and serial send combinations to see what works.

    The Code:

    ' {$STAMP BS2sx}
    ' {$PBASIC 2.5}
    SI············· PIN···· 0·············· ' serial input
    SO············· PIN···· 1·············· ' serial output
    letter········· VAR···· Byte
    Main:
    · DO
    ···· SERIN SI, 18447, [noparse][[/noparse]letter]········ ' receive one byte
    ···· DEBUG Letter··
    ···· SEROUT SO, 18447, [noparse][[/noparse]letter]···· ' comment this out to test with just debug
    · LOOP································· ' repeat
    · END
  • ToideToide Posts: 6
    edited 2006-06-13 00:40
    I haven't seen any GPS that works at 1200, what kind of hardware are you using?
  • ttessierttessier Posts: 14
    edited 2006-06-13 00:49
    Sorry, I should have mentioned that I've put away·the GPS for now and am·just using a terminal program at that is easily configurable to debug the serial link. By the way, I do get an output on pin 1, I scoped it and it looks nice & square.

    The reason I mention 1200 bps is because that is the only speed where a continuous stream of data will be properly formatted on the transmit side.
  • steve_bsteve_b Posts: 1,563
    edited 2006-06-13 16:22
    Jon Williams came up with a quick/easy way of grabbing GPS data with a BS2.

    It could certainly be adopted to the bs2sx

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

    Steve

    "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."
  • ttessierttessier Posts: 14
    edited 2006-06-13 17:24
    Thanks for the help, steve_b!! Nice to see a bit of poetry in an embedded hardware group as well...

    The code you included works with a Garmin, using thier binary string. The setup of the variables is a nice insight into how I could do the same. I'll put that to good use.

    Since my last post, I made progress. First thing I did was break down and go pick up a MAX233 for RS232 level shifting. I also searched through the literature on the upatch100 GPS I am using (the RS232 and 4800 bps version - I will use the cmos level one for next time so I won't need the MAX chip).

    I found that when using the GPS output-only, the input line has to be clamped high, to Vcc, in order for the 232 output level to be "full range" (as per a tech note they had online). Scoping it, "full range" still seems like only a few volts, but now the BS2sx is getting gibberish. Then I put in the MAX233 and I get a LOT of gibberish - progress! I used a WAIT statement, thus:

    SERIN 0,500,[noparse][[/noparse]WAIT("GPRMC,"),WAIT(",A,"), lat_high]

    and do get the first digit of may latitude!! REAL progress!

    Now I'll carry on with getting the rest of the digits. A great reference was:

    http://www.kd4rdb.com/bbs/viewtopic.php?p=141&sid=a2222f92bed536f4acd8dbe414e1e601

    Where KD4RDB so graciously put out his code on how he hooked up a GPS to a BS2 as part of a ham radio setup for APRS (see www.aprs.org). Many thanks, Wes!!

    By the way, the uPatch is a cool GPS implementation - antenna on one side, GPS on the backside of the antenna patch. I found it to be very sensitive. Great if all you need is an NMEA machine. For info:

    http://www.fastrax.fi/index.cfm?template=products.show.cfm&guid=560ffcd1-b2d1-4183-971d-b8cd274b6680
  • ToideToide Posts: 6
    edited 2006-06-13 22:14
    After your last post I look at my program and I notice if I just get a singel variable reading the data from the serial imput I got just garbage. After going back to my original setting using a "WAIT" everything works fine again. That is consistence with your findings and with the note in the manual that refers to the SP2sx not having input buffers.
  • steve_bsteve_b Posts: 1,563
    edited 2006-06-14 15:08
    Glad things are working for you ttessier!

    Have you tried interfacing to the GPS without a MAX chip?
    You can easily receive RS232 data with just your BS2. Check the PBasic help file on SERIN....it shows a circuit there to easily receive RS232 and not wreck your Stamp I/O pin. (I believe it's just a matter of a 22kohm resistor in series....check the help file)

    Anyhow, if you only need to serin, this is fine.
    You may also get lucky with serout'ing to that same device, some devices don't care of the actual voltage level. They just want to see a threshold breach....so over 1.4V it's one logic and under 1.4V it's a zero logic (Noting that RS232 will invert the logic for the given voltage levels)....
    Anyways, just in case you need to reduce some parts counts, you might be able to get away without one (Just be sure to change your baudvalue in your serin/serout commands (from true with the MAX chip; to inverted without the MAX chip).

    Cheers

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

    Steve

    "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."
  • ttessierttessier Posts: 14
    edited 2006-06-15 13:57
    I started programming without a RS232 converter chip - the BS2sx understood incoming messages but the other devices didn't understand the BS2sx output. Now that I have it working with the chip, I should take your suggestion and try the connection without the interface chip.

    Thank you for the reminder that the·input and output signals·will have to be inverted relative to the "phase" now - I would have wasted a lot of time figuring that one out! I would first test the value 16884 for 4800 bps and 18447 for 1200 bps, the opposite phases of what I am using now.

    Right now the values I am using that work are as follows. Hopefully this will be of help to others that are·trying to do the same thing that I figured out:

    *** GPS output to BS2sx through a MAX233 chip, at 4800 bps using 500 for true phase (noninverted):

    SERIN SI,500,[noparse][[/noparse]WAIT("GPRMC,"),WAIT(",A,"),DEC4 lat_deg,DEC4 lat_sec,WAIT(","),WAIT(","),DEC5 long_deg,DEC5 long_sec] 'get lat degrees & minutes, lat decimal seconds, long degrees & minutes, long decimal seconds from NMEA GPRMC string

    *** BS2sx output to a standalone modem through a MAX233 chip, at 1200 bps using 2063 for true phase(noninverted):

    SEROUT IrO,2063, [noparse][[/noparse]"AT",CR,LF]······ 'AT just to see if it's alive with debug output

    *** BS2sx input·from a standalone modem through a MAX233 chip, at 1200 bps using 2063 for true phase(noninverted):

    SERIN IrI, 2063, [noparse][[/noparse]STR Modem_reply\2] 'read into variable Modem_reply
  • steve_bsteve_b Posts: 1,563
    edited 2006-06-15 17:06
    Be careful calling labeling the true vs inverted instances as 'phases'.
    They're just how the signal is ciphered/deciphered with respect to logic levels. One expects a high to be a logic 1 and the other expects a high to be a logic 0.

    As far as your SERIN strings....doe the additoinal WAITs work? I would've thought that the time spent getting 'ready to wait' would mean you'd miss what you were waiting for. Although, I guess if it was far enough down the line it wouldn't matter.

    Glad you're making process though!

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

    Steve

    "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."
  • ttessierttessier Posts: 14
    edited 2006-06-16 04:47
    So far, the waits have worked without a hitch. I also put in some more code to do a count function on the "ready flag" output pin on the gps - works nicely. The GPS will toggle·the line every second when searching for sats, toggle it every 0.5 secs when tracking (less than 3 sats) and hold it steadily high once locked on enough sats to get a 3D position. I just make it loop until there are less than 2 counts in 4.5 seconds.

    Yes, the "phase" description·thing is a relic of my background in telemetry. We use the term "phase" of the signal when a bit synchronizer unit·locks on to a serial bit stream's synchronization words. Bit syncs· normally lock on to the signals's sine wave in "true" phase or "inverted" phase. Hard to shake that! If we had sync words on the RS232 lines· that the receivers could recognize, we wouldn't have to deal with the "true" or "inverted" dilemma. But then we'd be getting into something like the OSI networking model.

    -TT
  • steve_bsteve_b Posts: 1,563
    edited 2006-06-16 12:10
    Sounds neat....

    even though other GPS projects have been posted ( I think)....feel free to post your finished (or semi-finished) setup in the PROJECTS forum for others to see.

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

    Steve

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