Hi guys,
I've been trying to use a coridium basic chip for a high altitude ballooning project. All is well listening to the gps (ublox 6) on serial but I can't send messages to it
I'm just trying to send sentences such as the ones here http://ukhas.org.uk/guides:ublox6
ie the strings from
// Turning off all GPS NMEA strings apart from GPGGA on the uBlox modules
Serial.print("$PUBX,40,GLL,0,0,0,0*5C\r\n");
Serial.print("$PUBX,40,ZDA,0,0,0,0*44\r\n");
Serial.print("$PUBX,40,VTG,0,0,0,0*5E\r\n");
Serial.print("$PUBX,40,GSV,0,0,0,0*59\r\n");
Serial.print("$PUBX,40,GSA,0,0,0,0*4E\r\n");
Serial.print("$PUBX,40,RMC,0,0,0,0*47\r\n");
I'm sure I'm missing something basic out. Does anyone have an idea why it's not working?
my code (a little bit rough as its only testing the SEROUT)
#include <SERIAL.bas>
'SENDING DATA TO GPS
DIM BYTES(255) AS STRING
dim shortMessage(3)
INPUT(10)
bbBaud(10)=9600
OUTPUT(8)
bbBaud(8)=9600
do
BYTES=""
wait(10)
SERIN (10, 9600, 1, 255,BYTES)
SERIN (10, 9600, 1, 255,BYTES)
PRINT BYTES
SEROUT (8, 9600, 1, 23,"$PUBX,40,GLL,0,0,0,0*5C")'1g flight mode#
'wait(10)
SEROUT (8, 9600, 1, 23,"$PUBX,40,ZDA,0,0,0,0*44")'OFF NMEA GLL
'wait(10)
SEROUT (8, 9600, 1, 23,"$PUBX,40,VTG,0,0,0,0*5E")'Switching off NMEA GSA
'wait(10)
SEROUT (8, 9600, 1, 23,"$PUBX,40,GSV,0,0,0,0*59")'Switching off NMEA GSV
'wait(10)
SEROUT (8, 9600, 1, 23,"$PUBX,40,GSA,0,0,0,0*4E")'Switching off NMEA RMC
'wait(10)
SEROUT (8, 9600, 1, 23,"$PUBX,40,RMC,0,0,0,0*47")
'wait(10)
SEROUT (8, 9600, 1, 22,"1019861802401000001143")'switching of gll
'wait(10)
'SEROUT (10, 9600, 1, 22,[$101]) 'trying to send hex, not working
'chr(101)chr(98)Chr(6)chr(1)chr(8)chr(0)chr(240)chr(1)chr(0)chr(0)chr(0)chr(0)chr(0)chr(1)chr(1)chr(43)'decimal values of the hex trying to send
'shortMessage(0)= 101
' shortMessage(1) = 98
' shortMessage(2) = 6
'SEROUT(10,9600, 1, 10, shortMessage) 'trying to send array, not working
'print shortMessage
SERIN (10, 9600, 1, 255,BYTES)
PRINT BYTES
SERIN (10, 9600, 1, 255,BYTES)
PRINT BYTES
SERIN (10, 9600, 1, 255,BYTES)
PRINT BYTES
SERIN (10, 9600, 1, 255,BYTES)
PRINT BYTES
SERIN (10, 9600, 1, 255,BYTES)
PRINT BYTES
SERIN (10, 9600, 1, 255,BYTES)
PRINT BYTES
LOOP
Serial to ublox 6 gps
Re: Serial to ublox 6 gps
I can't speak to the syntax to the GPS, I know others out there have used similar devices
But your ShortMessage needs to be a string or byte array, not an array of integers, and the compiler will complain about that--
The same applies to sending a hex value, it has to be stored in a STRING or BYTE ARRAY before being sent
STRINGs are special cases of BYTE ARRAYs where the STRING is terminated by a character of 0. So while you can assign a byte to be 0, you can not use chr(0) in a STRING expression
But your ShortMessage needs to be a string or byte array, not an array of integers, and the compiler will complain about that--
Code: Select all
#include <SERIAL.bas>
DIM xx(20)
serout (10,9600,1,19,xx)
ERROR 25: Expected string variable, found xx)
ERROR 25: Expected End Of Line, found xx)
STRINGs are special cases of BYTE ARRAYs where the STRING is terminated by a character of 0. So while you can assign a byte to be 0, you can not use chr(0) in a STRING expression
Code: Select all
DIM XX{20) AS BYTE
XX = "somestring" + chr(0) + "another string" ' in this case the "another string" is not added because 0 terminates the string
XX = "something" + " " + "another string"
XX{9] = 0 ' does accomplish what you want
Re: Serial to ublox 6 gps
Finally understood what you mean and have working hex serial code
#include <SERIAL.bas>
SERINtimeout = 700000
'SENDING DATA TO GPS
DIM BYTES(255) AS STRING
dim serialarray(255) as BYTE
wait(3000)
serialarray=chr(&HB5)+chr(&H62)+chr(&H06)+chr(&H24)+chr(&H24)+" "+chr(&HFF)+chr(&HFF)+chr(&H06)+chr(&H03)+" "+" "+" "+" "+chr(&H10)+chr(&H27)+" "+" "'flight mode
serialarray(5)=0
serialarray(10)=0
serialarray(11)=0
serialarray(12)=0
serialarray(13)=0
serialarray(16)=0
serialarray(17)=0
SEROUT (8, 9600, 1, 17,serialarray)
wait(10)
serialarray=chr(&HB5)+chr(&H62)+chr(&H06)+chr(&H01)+chr(&H08)+" "+chr(&HF0)+chr(&H05)+" "+" "+" "+" "+" "+" "+chr(&H04)+chr(&H46)'vtg off
serialarray(5)=0
serialarray(9)=0
serialarray(10)=0
serialarray(11)=0
serialarray(12)=0
serialarray(13)=0
serialarray(8)=0
SEROUT (8, 9600, 1, 17,serialarray)
wait(10)
serialarray=chr(&HB5)+chr(&H62)+chr(&H06)+chr(&H01)+chr(&H08)+" "+chr(&HF0)+chr(&H01)+" "+" "+" "+" "+" "+chr(&H01)+chr(&H01)+chr(&H2B)'switch off gll
serialarray(5)=0
serialarray(9)=0
serialarray(10)=0
serialarray(11)=0
serialarray(12)=0
serialarray(8)=0
SEROUT (8, 9600, 1, 17,serialarray)
wait(10)
serialarray=chr(&HB5)+chr(&H62)+chr(&H06)+chr(&H01)+chr(&H08)+" "+chr(&HF0)+chr(&H04)+" "+" "+" "+" "+" "+chr(&H01)+chr(&H04)+chr(&H40)'off rmc
serialarray(5)=0
serialarray(9)=0
serialarray(10)=0
serialarray(11)=0
serialarray(12)=0
serialarray(8)=0
SEROUT (8, 9600, 1, 17,serialarray)
wait(10)
serialarray=chr(&HB5)+chr(&H62)+chr(&H06)+chr(&H01)+chr(&H08)+" "+chr(&HF0)+chr(&H02)+" "+" "+" "+" "+" "+chr(&H01)+chr(&H02)+chr(&H32)'off gsa
serialarray(5)=0
serialarray(9)=0
serialarray(10)=0
serialarray(11)=0
serialarray(12)=0
serialarray(8)=0
SEROUT (8, 9600, 1, 17,serialarray)
wait(10)
serialarray=chr(&HB5)+chr(&H62)+chr(&H06)+chr(&H01)+chr(&H08)+" "+chr(&HF0)+chr(&H03)+" "+" "+" "+" "+" "+chr(&H01)+chr(&H03)+chr(&H39)'off gsv
serialarray(5)=0
serialarray(9)=0
serialarray(10)=0
serialarray(11)=0
serialarray(12)=0
serialarray(8)=0
SEROUT (8, 9600, 1, 17,serialarray)
wait(10)
serialarray=chr(&HB5)+chr(&H62)+chr(&H06)+chr(&H01)+chr(&H08)+" "+chr(&HF0)+chr(&H03)+" "+" "+" "+" "+" "+chr(&H01)+chr(&H03)+chr(&H39)'off gsv
serialarray(5)=0
serialarray(9)=0
serialarray(10)=0
serialarray(11)=0
serialarray(12)=0
serialarray(8)=0
SEROUT (8, 9600, 1, 17,serialarray)
print "end setting gps"
do
BYTES=""
SERIN (10, 9600, 1, 255,BYTES)
PRINT BYTES
Print""
SERIN (10, 9600, 1, 255,BYTES)
PRINT BYTES
Print""
wait(10)
LOOP
now it outputs
$GPGGA,014259.00,5129.92967,N,00006.60898,W,1,04,2.57,48.2,M,45.6,M,,*7D
ÿ
etc
#include <SERIAL.bas>
SERINtimeout = 700000
'SENDING DATA TO GPS
DIM BYTES(255) AS STRING
dim serialarray(255) as BYTE
wait(3000)
serialarray=chr(&HB5)+chr(&H62)+chr(&H06)+chr(&H24)+chr(&H24)+" "+chr(&HFF)+chr(&HFF)+chr(&H06)+chr(&H03)+" "+" "+" "+" "+chr(&H10)+chr(&H27)+" "+" "'flight mode
serialarray(5)=0
serialarray(10)=0
serialarray(11)=0
serialarray(12)=0
serialarray(13)=0
serialarray(16)=0
serialarray(17)=0
SEROUT (8, 9600, 1, 17,serialarray)
wait(10)
serialarray=chr(&HB5)+chr(&H62)+chr(&H06)+chr(&H01)+chr(&H08)+" "+chr(&HF0)+chr(&H05)+" "+" "+" "+" "+" "+" "+chr(&H04)+chr(&H46)'vtg off
serialarray(5)=0
serialarray(9)=0
serialarray(10)=0
serialarray(11)=0
serialarray(12)=0
serialarray(13)=0
serialarray(8)=0
SEROUT (8, 9600, 1, 17,serialarray)
wait(10)
serialarray=chr(&HB5)+chr(&H62)+chr(&H06)+chr(&H01)+chr(&H08)+" "+chr(&HF0)+chr(&H01)+" "+" "+" "+" "+" "+chr(&H01)+chr(&H01)+chr(&H2B)'switch off gll
serialarray(5)=0
serialarray(9)=0
serialarray(10)=0
serialarray(11)=0
serialarray(12)=0
serialarray(8)=0
SEROUT (8, 9600, 1, 17,serialarray)
wait(10)
serialarray=chr(&HB5)+chr(&H62)+chr(&H06)+chr(&H01)+chr(&H08)+" "+chr(&HF0)+chr(&H04)+" "+" "+" "+" "+" "+chr(&H01)+chr(&H04)+chr(&H40)'off rmc
serialarray(5)=0
serialarray(9)=0
serialarray(10)=0
serialarray(11)=0
serialarray(12)=0
serialarray(8)=0
SEROUT (8, 9600, 1, 17,serialarray)
wait(10)
serialarray=chr(&HB5)+chr(&H62)+chr(&H06)+chr(&H01)+chr(&H08)+" "+chr(&HF0)+chr(&H02)+" "+" "+" "+" "+" "+chr(&H01)+chr(&H02)+chr(&H32)'off gsa
serialarray(5)=0
serialarray(9)=0
serialarray(10)=0
serialarray(11)=0
serialarray(12)=0
serialarray(8)=0
SEROUT (8, 9600, 1, 17,serialarray)
wait(10)
serialarray=chr(&HB5)+chr(&H62)+chr(&H06)+chr(&H01)+chr(&H08)+" "+chr(&HF0)+chr(&H03)+" "+" "+" "+" "+" "+chr(&H01)+chr(&H03)+chr(&H39)'off gsv
serialarray(5)=0
serialarray(9)=0
serialarray(10)=0
serialarray(11)=0
serialarray(12)=0
serialarray(8)=0
SEROUT (8, 9600, 1, 17,serialarray)
wait(10)
serialarray=chr(&HB5)+chr(&H62)+chr(&H06)+chr(&H01)+chr(&H08)+" "+chr(&HF0)+chr(&H03)+" "+" "+" "+" "+" "+chr(&H01)+chr(&H03)+chr(&H39)'off gsv
serialarray(5)=0
serialarray(9)=0
serialarray(10)=0
serialarray(11)=0
serialarray(12)=0
serialarray(8)=0
SEROUT (8, 9600, 1, 17,serialarray)
print "end setting gps"
do
BYTES=""
SERIN (10, 9600, 1, 255,BYTES)
PRINT BYTES
Print""
SERIN (10, 9600, 1, 255,BYTES)
PRINT BYTES
Print""
wait(10)
LOOP
now it outputs
$GPGGA,014259.00,5129.92967,N,00006.60898,W,1,04,2.57,48.2,M,45.6,M,,*7D
ÿ
etc