Parsing 4800 bps GPS strings with BS2sx
ttessier
Posts: 14
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
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.
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
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.
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."
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
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."
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
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."
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
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."