Serial Driver?
Archiver
Posts: 46,084
Hello,
I've just bought a Board Of Education Kit with BS2. And I'm all too
excited to have some fun with it. My first job for the chip is to
interpret a non-standard language spouted by a Motorola Oncore VP GPS
card (an OEM unit). But I'm having some trouble making sense of the
spew.
The GPS unit speaks serial TTL and its documentation recommends using
an RS-232 driver/receiver (Motorola MC145407). I've decided to use a
Maxim chip, MAX232CPE. As far as I can tell, this should make no
difference.
In the BS2, I'm using the following:
'{$STAMP BS2}
DataIn VAR BYTE
sbm9600 CON 16468
GetData:
SERIN 0,sbm9600,[noparse][[/noparse]DataIn]
DEBUG DataIn
GOTO GetData
All I'm able to get back is garbage text. I've tried Conversion
Formatters in all imaginable configurations, different serial rates,
and variable lengths. But the most I get is garbage.
How can I receive the data that this card is spouting out? Then, once
I've figured that out, I'll be reversing the method to speak to the
card and issue commands to it.
Thanks for your help,
- Mario
I've just bought a Board Of Education Kit with BS2. And I'm all too
excited to have some fun with it. My first job for the chip is to
interpret a non-standard language spouted by a Motorola Oncore VP GPS
card (an OEM unit). But I'm having some trouble making sense of the
spew.
The GPS unit speaks serial TTL and its documentation recommends using
an RS-232 driver/receiver (Motorola MC145407). I've decided to use a
Maxim chip, MAX232CPE. As far as I can tell, this should make no
difference.
In the BS2, I'm using the following:
'{$STAMP BS2}
DataIn VAR BYTE
sbm9600 CON 16468
GetData:
SERIN 0,sbm9600,[noparse][[/noparse]DataIn]
DEBUG DataIn
GOTO GetData
All I'm able to get back is garbage text. I've tried Conversion
Formatters in all imaginable configurations, different serial rates,
and variable lengths. But the most I get is garbage.
How can I receive the data that this card is spouting out? Then, once
I've figured that out, I'll be reversing the method to speak to the
card and issue commands to it.
Thanks for your help,
- Mario
Comments
device. Even if the device IS RS232 levels you can still use it without the
MAX 232 device by inserting a series resistor (to limit the current)in the
data line going TO the Stamp. MOST Rs232 devices will recieve data FROM the
Stamp a TTL level and work Just fine. In your application there isn't much
to send TO the GPS so the short answer is the MAX device will work just fine
if needed or just use a series resistor..
Mike B.
Original Message
From: <roens@b...>
To: <basicstamps@yahoogroups.com>
Sent: Friday, December 20, 2002 9:41 PM
Subject: [noparse][[/noparse]basicstamps] Serial Driver?
> Hello,
>
> I've just bought a Board Of Education Kit with BS2. And I'm all too
> excited to have some fun with it. My first job for the chip is to
> interpret a non-standard language spouted by a Motorola Oncore VP GPS
> card (an OEM unit). But I'm having some trouble making sense of the
> spew.
>
> The GPS unit speaks serial TTL and its documentation recommends using
> an RS-232 driver/receiver (Motorola MC145407). I've decided to use a
> Maxim chip, MAX232CPE. As far as I can tell, this should make no
> difference.
>
> In the BS2, I'm using the following:
>
> '{$STAMP BS2}
> DataIn VAR BYTE
> sbm9600 CON 16468
>
> GetData:
> SERIN 0,sbm9600,[noparse][[/noparse]DataIn]
> DEBUG DataIn
> GOTO GetData
>
> All I'm able to get back is garbage text. I've tried Conversion
> Formatters in all imaginable configurations, different serial rates,
> and variable lengths. But the most I get is garbage.
>
> How can I receive the data that this card is spouting out? Then, once
> I've figured that out, I'll be reversing the method to speak to the
> card and issue commands to it.
>
> Thanks for your help,
> - Mario
>
>
>
>
> To UNSUBSCRIBE, just send mail to:
> basicstamps-unsubscribe@yahoogroups.com
> from the same email address that you subscribed. Text in the Subject and
Body of the message will be ignored.
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>
>
Here's some code I used successfully with my Oncore GT unit. I
connect the Stamp directly to the I/O pins on the GPS (no MAX or
Moto converters, which are only needed if connecting to PC serial
port). Pls closely guard the coordinates shown below, which are in
fact the lat/long of my secret volcano base.
Regards,
Steve
'{$STAMP BS2}
' __________
' SER TX <-| 1 24 |-- PWR
' SER RX ->| 2 23 |-- (PWR) GND
' SER ATN ->| 3 22 |-- RESET
' SER GND --| 4 21 |-- +5V
' I/O 0 --| 5 20 |-- I/O F
' I/O 1 --| 6 19 |-- I/O E
' I/O 2 --| 7 18 |-- I/O D
' I/O 3 --| 8 17 |-- I/O C
' I/O 4 --| 9 16 |-- I/O B
' I/O 5 --| 10 15 |-- I/O A
' I/O 6 --| 11 14 |-- I/O 9
' Gps_in I/O 7 ->| 12 13 |-> I/O 8 Gps_out
' |__________|
'
' BS2-IC
Gps_in CON 7
Gps_out CON 8
Bin_baud CON 84 ' 9600,8,n,1 (true)
Nmea_baud CON 188 ' 4800,8,n,1 (true)
LF CON $0A
checksum VAR BYTE
month VAR BYTE
day VAR BYTE
year VAR WORD
hour VAR month
minute VAR day
second VAR year.LOWBYTE
i VAR BYTE
x VAR BYTE(20)
DEBUG CLS
again:
PAUSE 1000
' ensure in Motorola binary format to start
SEROUT Gps_out,Nmea_baud,[noparse][[/noparse]"$PMOTG,FOR,0",CR,LF]
PAUSE 1000
' poll date
checksum = "A"^"c"
SEROUT Gps_out,Bin_baud,[noparse][[/noparse]"@@Ac",$FF, $FF, $FF, $FF,checksum,CR,LF]
SERIN Gps_in,Bin_baud,[noparse][[/noparse]STR x\4,month,day,year.HIGHBYTE,year.LOWBYTE]
DEBUG CR, "Date: ",DEC month,"/",DEC day,"/",DEC year
' set date, handle response
year = 2002: month = 9: day = 29
checksum = "A"^"c"^month^day^year.HIGHBYTE^year.LOWBYTE
SEROUT
Gps_out,Bin_baud,[noparse][[/noparse]"@@Ac",month,day,year.HIGHBYTE,year.LOWBYTE,checksum,CR,LF]
month = 0: day = 0: year = 0
SERIN Gps_in,Bin_baud,[noparse][[/noparse]STR x\4,month,day,year.HIGHBYTE,year.LOWBYTE]
DEBUG CR, "Date: ",DEC month,"/",DEC day,"/",DEC year
' poll clock
checksum = "A"^"a"^$FF
SEROUT Gps_out,Bin_baud,[noparse][[/noparse]"@@Aa",$FF,$FF,$FF,checksum,CR,LF]
SERIN Gps_in,Bin_baud,[noparse][[/noparse]STR x\4,hour,minute,second]
DEBUG CR, "Time: ", DEC hour,":",DEC minute,":",DEC second
' set clock, handle response
hour = 23: minute = 59: second = 35
checksum = "A"^"a"^hour^minute^second
SEROUT Gps_out,Bin_baud,[noparse][[/noparse]"@@Aa",hour,minute,second,checksum,CR,LF]
hour = 0: minute = 0: second = 0
SERIN Gps_in,Bin_baud,[noparse][[/noparse]STR x\4,hour,minute,second]
DEBUG CR, "Time: ", DEC hour,":",DEC minute,":",DEC second
' get receiver ID (first 20 bytes of response)
checksum = "C"^"j"
SEROUT Gps_out,Bin_baud,[noparse][[/noparse]"@@Cj",checksum,CR,LF]
SERIN Gps_in,Bin_baud,[noparse][[/noparse]STR x\20]
DEBUG CR,"Receiver ID: ", STR x\20
pause 500
' set GMT offset to -9 hours, handle response
checksum = "A"^"b"^$FF^9
SEROUT Gps_out,Bin_baud,[noparse][[/noparse]"@@Ab",$FF,9,0,checksum,CR,LF]
SERIN Gps_in,Bin_baud,[noparse][[/noparse]STR x\7]
DEBUG CR, "GMT Offset: ", HEX2 x(4), " ", DEC x(5), " ", DEC x(6)
' set time mode
checksum = "A"^"w"^1
SEROUT Gps_out,Bin_baud,[noparse][[/noparse]"@@Aw",1, checksum,CR,LF]
SERIN Gps_in,Bin_baud,[noparse][[/noparse]STR x\6]
DEBUG CR,"Time Mode: ", DEC x(4)
' poll latitude
checksum = "A"^"d"
SEROUT Gps_out,Bin_baud,[noparse][[/noparse]"@@Ad", 99, 99, 99, 99, checksum,CR,LF]
SERIN Gps_in,Bin_baud,[noparse][[/noparse]STR x\8]
DEBUG CR,"Lat: ", HEX2 x(4), HEX2 x(5), HEX2 x(6), HEX2 x(7)
' poll longitude
checksum = "A"^"e"
SEROUT Gps_out,Bin_baud,[noparse][[/noparse]"@@Ae", 99, 99, 99, 99, checksum,CR,LF]
SERIN Gps_in,Bin_baud,[noparse][[/noparse]STR x\8]
DEBUG CR,"Long: ", HEX2 x(4), HEX2 x(5), HEX2 x(6), HEX2 x(7)
' poll height
checksum = "A"^"f"^99
SEROUT Gps_out,Bin_baud,[noparse][[/noparse]"@@Af", 99, 99, 99, 99, 99, checksum,CR,LF]
SERIN Gps_in,Bin_baud,[noparse][[/noparse]STR x\8]
DEBUG CR,"Height: ", HEX2 x(4), HEX2 x(5), HEX2 x(6), HEX2 x(7)
' set latitude
checksum = "A"^"d"^$07^$B7^$A0^$10
SEROUT Gps_out,Bin_baud,[noparse][[/noparse]"@@Ad",$07, $B7, $A0, $10, checksum,CR,LF]
SERIN Gps_in,Bin_baud,[noparse][[/noparse]STR x\8]
DEBUG CR,"Lat: ", HEX2 x(4), HEX2 x(5), HEX2 x(6), HEX2 x(7)
' set longitude
checksum = "A"^"e"^$18^$A4^$54^$94
SEROUT Gps_out,Bin_baud,[noparse][[/noparse]"@@Ae",$18, $A4, $54, $94, checksum,CR,LF]
SERIN Gps_in,Bin_baud,[noparse][[/noparse]STR x\8]
DEBUG CR,"Long: ", HEX2 x(4), HEX2 x(5), HEX2 x(6), HEX2 x(7)
' set height
checksum = "A"^"f"^100
SEROUT Gps_out,Bin_baud,[noparse][[/noparse]"@@Af", 0, 0, 0, 100, 0, checksum,CR,LF]
SERIN Gps_in,Bin_baud,[noparse][[/noparse]STR x\8]
DEBUG CR,"Height: ", HEX2 x(4), HEX2 x(5), HEX2 x(6), HEX2 x(7)
' get position/status
checksum = "E"^"a"
SEROUT Gps_out,Bin_baud,[noparse][[/noparse]"@@Ea", 0, checksum,CR,LF]
SERIN Gps_in,Bin_baud,[noparse][[/noparse]STR x\20]
DEBUG CR,"Position/Status: "
FOR i = 4 TO 19
DEBUG HEX2 x( i ), " "
NEXT
' poll sat mask angle
checksum = "A"^"g"^$FF
SEROUT Gps_out,Bin_baud,[noparse][[/noparse]"@@Ag", $FF, checksum,CR,LF]
SERIN Gps_in,Bin_baud,[noparse][[/noparse]STR x\6]
DEBUG CR,"Sat mask angle: ", HEX2 x(4)
' set sat mask angle
checksum = "A"^"g"^10
SEROUT Gps_out,Bin_baud,[noparse][[/noparse]"@@Ag", 10, checksum,CR,LF]
SERIN Gps_in,Bin_baud,[noparse][[/noparse]STR x\6]
DEBUG CR,"Sat mask angle: ", HEX2 x(4)
' poll visible sat's
checksum = "B"^"b"
SEROUT Gps_out,Bin_baud,[noparse][[/noparse]"@@Bb", 0, checksum,CR,LF]
SERIN Gps_in,Bin_baud,[noparse][[/noparse]STR x\6]
DEBUG CR,"Visible sats: "
FOR i = 0 TO 19
DEBUG HEX2 x( i ), " "
NEXT
' poll leap second pending status
checksum = "B"^"j"
SEROUT Gps_out,Bin_baud,[noparse][[/noparse]"@@Bj", 0, checksum,CR,LF]
SERIN Gps_in,Bin_baud,[noparse][[/noparse]STR x\6]
DEBUG CR,"Leap sec: ", DEC x(4)
' poll atmospheric correction
checksum = "A"^"q"^$FF
SEROUT Gps_out,Bin_baud,[noparse][[/noparse]"@@Aq", $FF, checksum,CR,LF]
SERIN Gps_in,Bin_baud,[noparse][[/noparse]STR x\6]
DEBUG CR,"Atmos correction: ", DEC x(4)
' poll ASCII position msg
checksum = "E"^"q"
SEROUT Gps_out,Bin_baud,[noparse][[/noparse]"@@Eq", 0, checksum,CR,LF]
SERIN Gps_in,Bin_baud,[noparse][[/noparse]STR x\20]
DEBUG CR,"ASCII position: ", STR x\20
PAUSE 100
' poll velocity filter
checksum = "A"^"N"^$FF
SEROUT Gps_out,Bin_baud,[noparse][[/noparse]"@@AN", $FF, checksum,CR,LF]
SERIN Gps_in,Bin_baud,[noparse][[/noparse]STR x\6]
DEBUG CR,"Velocity filter: ", DEC x(4),cr
FOR i = 0 TO 19
DEBUG HEX2 x( i ), " "
NEXT
' get status
checksum = "F"^"a"
SEROUT Gps_out,Bin_baud,[noparse][[/noparse]"@@Fa",checksum,CR,LF]
SERIN Gps_in,Bin_baud,[noparse][[/noparse]STR x\6]
DEBUG CR, "Status: ", BIN8 x(4),"_",BIN8 x(5)
' go to NMEA mode
checksum = "C"^"i"^1
SEROUT Gps_out,Bin_baud,[noparse][[/noparse]"@@Ci",1,checksum,CR,LF]
' prompt for GPRMC msg
PAUSE 1000
SEROUT Gps_out,Nmea_baud,[noparse][[/noparse]"$PMOTG,RMC,0",CR,LF] ' one-time GPRMC msg
SERIN Gps_in,Nmea_baud,[noparse][[/noparse]STR x\10]
DEBUG CR,"rmc: ", STR x\20
' prompt for GPGGA msg
PAUSE 1000
SEROUT Gps_out,Nmea_baud,[noparse][[/noparse]"$PMOTG,GGA,0",CR,LF] ' one-time GPGGA msg
SERIN Gps_in,Nmea_baud,[noparse][[/noparse]STR x\20]
DEBUG CR,"gga: ", STR x\20
' prompt for GPGSA msg
PAUSE 1000
SEROUT Gps_out,Nmea_baud,[noparse][[/noparse]"$PMOTG,GSA,0",CR,LF] ' one-time GPGSA msg
SERIN Gps_in,Nmea_baud,[noparse][[/noparse]STR x\20]
DEBUG CR,"gsa: ", STR x\20
' prompt for GPGSV msg
PAUSE 1000
SEROUT Gps_out,Nmea_baud,[noparse][[/noparse]"$PMOTG,GSV,0",CR,LF] ' one-time GPGSV msg
SERIN Gps_in,Nmea_baud,[noparse][[/noparse]STR x\20]
DEBUG CR,"gsv: ", STR x\20
' prompt for GPVTG msg
PAUSE 1000
SEROUT Gps_out,Nmea_baud,[noparse][[/noparse]"$PMOTG,VTG,0",CR,LF] ' one-time GPZDA msg
SERIN Gps_in,Nmea_baud,[noparse][[/noparse]STR x\20]
DEBUG CR,"vtg: ", STR x\20
GOTO again