hi,I also read that to get 9600 Baud rate, 4MHz crystal is not the best. Whether that's true is another thing! but I'm exploring this area at the moment.
Where did you read that, I often use 4MHz for 9600 or 19200 Baud with no problems.
E
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
hi,I also read that to get 9600 Baud rate, 4MHz crystal is not the best. Whether that's true is another thing! but I'm exploring this area at the moment.
hi,
Where did you read that, I often use 4MHz for 9600 or 19200 Baud with no problems.
E
As there's a signal at the PIC RX, the problem seems to be with the PIC input
Have you confirmed what is actually is being output from the module, using a PC program, its important that we can see the details of the message string.?
Have you confirmed what is actually is being output from the module, using a PC program, its important that we can see the details of the message string.?
hi C,You will notice that there are 2 $GPGSV sentences next to each other, I've counted 4 the same in other instances
hi C,
I will look at the $GPGSV messages in the d/s.
The $GPGSV is the satellites in view message, so it may change.
Eric
C,
I believe that the Azimuth and Elevation are the actual satellite bearings in degrees, will this be accurate enough for your project.?
E
EDIT:
The GGA message will give the Ground position and Altitude above MSL
hi C,
It would be helpful if you could summarise the working application, I have only seen 'snippets' of the planned project.
If its a multipurpose application perhaps we could concentrate on on just one aspect for the time being.
Maybe a sketch of the App.
Eric
I may be wrong, but I think that you get those angles only to gps satellites.E,
- Actually, I was thinking about more of a calculation and chose $GPGGA, but $GPGSV shows amongst other things, Azimuth and Altitude. How I understand it, is, all I need are these two, and no calculation?
C.
I may be wrong, but I think that you get those angles only to gps satellites.
You need the calculations with nearby objects.
Btw the calculations are not so hard, there are a lot of examples in the net, for example:https://www.movable-type.co.uk/scripts/latlong.html
Oshonsoft Basic is missing the arctan function, so it has to be programmed.
'- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -
'Just read the GPS written by paul swingewood
'March 2013 - PIC 16F628A
'--------------------------------------------------------------------------
Define SIMULATION_WAITMS_VALUE = 1
'No Fix - added CR
'$GPGGA,,,,,,0,,,,,,,,*66
'Fix - added CR
'$GPGGA,183238.0,5233.736,N,00153.799,W,1,5,1.28,00 177,M,048,M,,*7B
'$$møtvu, 135738.ø, 5233.738, n, øø153.8øøw161.46øø1728mmø488mm,,
Define CONF_WORD = 0x3f50 'Internal Oscillator'
Define CLOCK_FREQUENCY = 4
osccon = %01101000
AllDigital
'Define the comms for the LCD display.
Define LCD_LINES = 4
Define LCD_CHARS = 20
Define LCD_BITS = 4
Define LCD_DREG = PORTB
Define LCD_DBIT = 4 'Use the high order bits'
Define LCD_RSREG = PORTA
Define LCD_RSBIT = 2
Define LCD_EREG = PORTA
Define LCD_EBIT = 0
Define LCD_RWREG = PORTA
Define LCD_RWBIT = 1
Define LCD_READ_BUSY_FLAG = 1
Define LCD_COMMANDUS = 5000 'delay after LCDCMDOUT, default value is 5000
Define LCD_DATAUS = 100 'delay after LCDOUT, default value is 100
Define LCD_INITMS = 20
Define SEROUT_DELAYUS = 1000
'-------------------------------------
'Arrays
'---------------------------------------
Dim data_byte(80) As Byte
Dim send_data_byte(42) As Byte '$$MØTVU,1ØØ632,5233.737,-1153.8ØØ,7,ØØ18Ø,*Ø832
'--------------------------------------------------
'variables
'----------------------------------------------------
Symbol txcr_pin = PORTA.7
Dim i As Byte 'used as array element loop
Dim j As Byte 'used for loops
Dim sentence_id As Byte
Dim ch As Byte 'used to hold individual character
Dim char As Byte
Dim sepchar As Byte
Dim array_ix As Byte
Dim send_ix As Byte
Dim field As Byte
Dim pos As Byte
'---------------------------
'crc variables
'--------------------------
Dim data_word As Word
Dim crc As Word
Dim bt As Byte
Dim tmp As Word
Dim polynomial As Word
Dim n0 As Byte
Dim n1 As Byte
Dim n2 As Byte
Dim n3 As Byte
polynomial = 0x1021 '0x1021 -
startup:
Lcdinit LcdCurBlink
Lcdcmdout LcdClear
WaitMs 2000 'Give everything time to power up 2 seconds?
'---------------------------------------------------
'Set initial Values
'----------------------------------------------------
sepchar = "," 'set the separator character, in this case a comma
sentence_id = 0
Lcdcmdout LcdLine1Pos(1)
Lcdout "LAT "
Lcdcmdout LcdLine2Pos(1)
Lcdout "LNG "
Hseropen 4800 'open hardware serial comms
start:
field = 0
array_ix = 6 'first space after the callsign has been inserted
'-------------------------------------------
'Load the callsign into the data_byte array
'-------------------------------------------
For i = 0 To 5 '21
data_byte(i) = LookUp("M0TVU,"), i '$$ will be added for send
Next i
'------------------------------------------------------------------
'Read the GPS
'------------------------------------------------------------------
RCSTA.CREN = 0 'flush
RCSTA.CREN = 1 'the buffer
char = 0xff 'Make sure char is not set to *
While char <> "*"
Gosub getsubstring
Wend
If field < 14 Then 'bad data!!!
Goto start
Endif
field = 0
'---------------------------------------
'Load the send_data_byte arry (What is actually sent)
'-------------------------------------------------------
Gosub load_send_data_byte
'---------------------------------------
'Arrays are loaded now spit the data out
'---------------------------------------
pos = 5
For i = 13 To 20
Lcdcmdout LcdLine1Pos(pos)
Lcdout send_data_byte(i)
pos = pos + 1
Next i
pos = 5
For i = 22 To 29
Lcdcmdout LcdLine2Pos(pos)
Lcdout send_data_byte(i)
pos = pos + 1
Next i
Gosub calculate_crc
Call word2nibbles(crc)
n3 = nibble2ascii(n3)
n2 = nibble2ascii(n2) 'populate the nibbles ready for sending
n1 = nibble2ascii(n1)
n0 = nibble2ascii(n0)
'Gosub send_callsign
'Gosub send_time
'Gosub send_lat
'Gosub send_lng
'Gosub send_num_sats
'Gosub send_alt
'--- SELECTED DATA
ch = "$"
Call convert_char(ch) 'Start
ch = "$"
Call convert_char(ch)
'--- Selected Data ---
For i = 0 To send_ix
ch = send_data_byte(i)
Call convert_char(ch) 'Data
Next i
ch = "*"
Call convert_char(ch) '*before CRC
Call convert_char(n3)
Call convert_char(n2)
Call convert_char(n1) 'send the crc
Call convert_char(n0)
ch = 13
Call convert_char(ch) 'don't forget the CR
Goto start
End
'-----------------------------------------------------
'Sub Routines
'-----------------------------------------------------
getsubstring: 'this is the parsing subroutine
While char <> sepchar 'while we are not reading the separator character...
If RCSTA.OERR = True Then
RCSTA.CREN = 0 'flush
RCSTA.CREN = 1 'the buffer
Lcdcmdout LcdClear
Lcdcmdout LcdLine1Pos(1)
Lcdout "OVERFLOW! - 1"
Halt
Endif
Hserin char
Wend
char = 0xff 'and set char To something other than the separator
While char <> sepchar 'while we are not reading the separator character...
If RCSTA.OERR = True Then
RCSTA.CREN = 0 'flush
RCSTA.CREN = 1 'the buffer
Lcdcmdout LcdClear
Lcdcmdout LcdLine2Pos(1)
Lcdout "OVERFLOW! - 2"
Halt
Endif
Hserin char 'get the next character
If char = sepchar Or char = "*" Then
data_byte(array_ix) = ","
array_ix = array_ix + 1
field = field + 1
Return
Endif 'if it's a terminator, return
'-----------------------------------------------
'Load the data_byte array
'-----------------------------------------------
data_byte(array_ix) = char
array_ix = array_ix + 1
'Lcdcmdout LcdLine1Pos(7)
'Lcdout #array_ix
Wend
Return
'$GPGGA,183238.0,5233.736,N,00153.799,W,1,5,1.28,00177,M,048,M,,*7B
'$GPGGA, - 0 to 5
'183238.0, - 6 to 11 (igonre decial place)
'5233.736, - 15 to 23
'N,
'00153.799, -28 to 35 (ignore first 0's)
'W, - 36
'1,
'5, - 40 to 41 - Number of satellites
'1.28,
'00177, - 47 to 51 Altitude
'M,
'048,
'M,,*7B
'$$MØTVU,1ØØ632,5233.737,-1153.8ØØ,7,ØØ18Ø,*Ø832
load_send_data_byte:
send_ix = 0
'Load callsign
For i = 0 To 5
send_data_byte(send_ix) = data_byte(i)
send_ix = send_ix + 1
Next i
'load sentence id
'send_data_byte(7) = "0"
'send_ix = send_ix + 1
'send_data_byte(8) = ","
'send_ix = send_ix + 1
'Load Time
For i = 6 To 11
send_data_byte(send_ix) = data_byte(i)
send_ix = send_ix + 1
Next i
'add a comma
send_data_byte(send_ix) = ","
send_ix = send_ix + 1
'Load Latitude
For i = 15 To 23
send_data_byte(send_ix) = data_byte(i)
send_ix = send_ix + 1
Next i
'Load Longditude
If data_byte(36) = 0x57 Then
send_data_byte(send_ix) = "-"
send_ix = send_ix + 1
For i = 28 To 35
send_data_byte(send_ix) = data_byte(i)
send_ix = send_ix + 1
Next i
Else
'raw data here
Endif
'load number of satellites
For i = 40 To 41
send_data_byte(send_ix) = data_byte(i)
send_ix = send_ix + 1
Next i
'load altitude
For i = 47 To 52
send_data_byte(send_ix) = data_byte(i)
send_ix = send_ix + 1
Next i
send_ix = send_ix - 1
Return
calculate_crc:
'-----------------------------------------
'This should be a function
'-----------------------------------------
crc = 0xffff
For i = 0 To send_ix
data_word = send_data_byte(i)
data_word = ShiftLeft(data_word, 8) 'shift the data left 8
crc = crc Xor data_word 'XOR the data with the CRC
For bt = 0 To 7
tmp = crc And 0x8000 'and the CRC with 0x8000
If tmp <> 0 Then 'if this vale <> 0 then will be either 8000 or 0
crc = ShiftLeft(crc, 1) 'shift the CRC left 1
crc = crc Xor polynomial 'XOR the CRC with polynomial
Else
crc = ShiftLeft(crc, 1) 'else just shift the crc left 1
Endif
Next bt
Next i
Return
'-------------------------------------------------
'Procedures
'-------------------------------------------------
Proc word2nibbles(word1 As Word)
Dim temp1 As Word
temp1 = word1 And 0x000f
n0 = temp1.LB
word1 = word1 / 16
temp1 = word1 And 0x000f
n1 = temp1.LB
word1 = word1 / 16
temp1 = word1 And 0x000f
n2 = temp1.LB
word1 = word1 / 16
temp1 = word1 And 0x000f
n3 = temp1.LB
word1 = word1 / 16
End Proc
'-------------------------------------------------------------
'Functions
'--------------------------------------------------------------
Function nibble2ascii(byte1 As Byte) As Byte
nibble2ascii = LookUp("0123456789ABCDEF"), byte1
End Function
Function convert_char(chr As Byte) As Byte
Call rtty_txbit(0) 'start Bit
For j = 0 To 7 'ascii-7 / ascii-8
If chr.0 Then
Call rtty_txbit(1)
Else
Call rtty_txbit(0)
Endif
chr = ShiftRight(chr, 1)
Next j
Call rtty_txbit(1) 'stop Bit
Call rtty_txbit(1) 'stop Bit
End Function
Function rtty_txbit(b As Bit) As Bit
If b = 1 Then
'High
High txcr_pin
Else
'Low
Low txcr_pin
Endif
WaitUs 20000 '1/50th of a second = 50 Baud? -20000
End Function
'M = 30873 - 7899
'M0 = 20684 - 50CC
Hi Camerart.
Note sure if this is helpful but here is my code for reading NMEA and transmitting it via RTTY. There might be bits of the code that you find useful. The CRC routines for example. This code is based around the UKHAS protocol.
Code:'- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - 'Just read the GPS written by paul swingewood 'March 2013 - PIC 16F628A '-------------------------------------------------------------------------- Define SIMULATION_WAITMS_VALUE = 1 'No Fix - added CR '$GPGGA,,,,,,0,,,,,,,,*66 'Fix - added CR '$GPGGA,183238.0,5233.736,N,00153.799,W,1,5,1.28,00 177,M,048,M,,*7B '$$møtvu, 135738.ø, 5233.738, n, øø153.8øøw161.46øø1728mmø488mm,, Define CONF_WORD = 0x3f50 'Internal Oscillator' Define CLOCK_FREQUENCY = 4 osccon = %01101000 AllDigital 'Define the comms for the LCD display. Define LCD_LINES = 4 Define LCD_CHARS = 20 Define LCD_BITS = 4 Define LCD_DREG = PORTB Define LCD_DBIT = 4 'Use the high order bits' Define LCD_RSREG = PORTA Define LCD_RSBIT = 2 Define LCD_EREG = PORTA Define LCD_EBIT = 0 Define LCD_RWREG = PORTA Define LCD_RWBIT = 1 Define LCD_READ_BUSY_FLAG = 1 Define LCD_COMMANDUS = 5000 'delay after LCDCMDOUT, default value is 5000 Define LCD_DATAUS = 100 'delay after LCDOUT, default value is 100 Define LCD_INITMS = 20 Define SEROUT_DELAYUS = 1000 '------------------------------------- 'Arrays '--------------------------------------- Dim data_byte(80) As Byte Dim send_data_byte(42) As Byte '$$MØTVU,1ØØ632,5233.737,-1153.8ØØ,7,ØØ18Ø,*Ø832 '-------------------------------------------------- 'variables '---------------------------------------------------- Symbol txcr_pin = PORTA.7 Dim i As Byte 'used as array element loop Dim j As Byte 'used for loops Dim sentence_id As Byte Dim ch As Byte 'used to hold individual character Dim char As Byte Dim sepchar As Byte Dim array_ix As Byte Dim send_ix As Byte Dim field As Byte Dim pos As Byte '--------------------------- 'crc variables '-------------------------- Dim data_word As Word Dim crc As Word Dim bt As Byte Dim tmp As Word Dim polynomial As Word Dim n0 As Byte Dim n1 As Byte Dim n2 As Byte Dim n3 As Byte polynomial = 0x1021 '0x1021 - startup: Lcdinit LcdCurBlink Lcdcmdout LcdClear WaitMs 2000 'Give everything time to power up 2 seconds? '--------------------------------------------------- 'Set initial Values '---------------------------------------------------- sepchar = "," 'set the separator character, in this case a comma sentence_id = 0 Lcdcmdout LcdLine1Pos(1) Lcdout "LAT " Lcdcmdout LcdLine2Pos(1) Lcdout "LNG " Hseropen 4800 'open hardware serial comms start: field = 0 array_ix = 6 'first space after the callsign has been inserted '------------------------------------------- 'Load the callsign into the data_byte array '------------------------------------------- For i = 0 To 5 '21 data_byte(i) = LookUp("M0TVU,"), i '$$ will be added for send Next i '------------------------------------------------------------------ 'Read the GPS '------------------------------------------------------------------ RCSTA.CREN = 0 'flush RCSTA.CREN = 1 'the buffer char = 0xff 'Make sure char is not set to * While char <> "*" Gosub getsubstring Wend If field < 14 Then 'bad data!!! Goto start Endif field = 0 '--------------------------------------- 'Load the send_data_byte arry (What is actually sent) '------------------------------------------------------- Gosub load_send_data_byte '--------------------------------------- 'Arrays are loaded now spit the data out '--------------------------------------- pos = 5 For i = 13 To 20 Lcdcmdout LcdLine1Pos(pos) Lcdout send_data_byte(i) pos = pos + 1 Next i pos = 5 For i = 22 To 29 Lcdcmdout LcdLine2Pos(pos) Lcdout send_data_byte(i) pos = pos + 1 Next i Gosub calculate_crc Call word2nibbles(crc) n3 = nibble2ascii(n3) n2 = nibble2ascii(n2) 'populate the nibbles ready for sending n1 = nibble2ascii(n1) n0 = nibble2ascii(n0) 'Gosub send_callsign 'Gosub send_time 'Gosub send_lat 'Gosub send_lng 'Gosub send_num_sats 'Gosub send_alt '--- SELECTED DATA ch = "$" Call convert_char(ch) 'Start ch = "$" Call convert_char(ch) '--- Selected Data --- For i = 0 To send_ix ch = send_data_byte(i) Call convert_char(ch) 'Data Next i ch = "*" Call convert_char(ch) '*before CRC Call convert_char(n3) Call convert_char(n2) Call convert_char(n1) 'send the crc Call convert_char(n0) ch = 13 Call convert_char(ch) 'don't forget the CR Goto start End '----------------------------------------------------- 'Sub Routines '----------------------------------------------------- getsubstring: 'this is the parsing subroutine While char <> sepchar 'while we are not reading the separator character... If RCSTA.OERR = True Then RCSTA.CREN = 0 'flush RCSTA.CREN = 1 'the buffer Lcdcmdout LcdClear Lcdcmdout LcdLine1Pos(1) Lcdout "OVERFLOW! - 1" Halt Endif Hserin char Wend char = 0xff 'and set char To something other than the separator While char <> sepchar 'while we are not reading the separator character... If RCSTA.OERR = True Then RCSTA.CREN = 0 'flush RCSTA.CREN = 1 'the buffer Lcdcmdout LcdClear Lcdcmdout LcdLine2Pos(1) Lcdout "OVERFLOW! - 2" Halt Endif Hserin char 'get the next character If char = sepchar Or char = "*" Then data_byte(array_ix) = "," array_ix = array_ix + 1 field = field + 1 Return Endif 'if it's a terminator, return '----------------------------------------------- 'Load the data_byte array '----------------------------------------------- data_byte(array_ix) = char array_ix = array_ix + 1 'Lcdcmdout LcdLine1Pos(7) 'Lcdout #array_ix Wend Return '$GPGGA,183238.0,5233.736,N,00153.799,W,1,5,1.28,00177,M,048,M,,*7B '$GPGGA, - 0 to 5 '183238.0, - 6 to 11 (igonre decial place) '5233.736, - 15 to 23 'N, '00153.799, -28 to 35 (ignore first 0's) 'W, - 36 '1, '5, - 40 to 41 - Number of satellites '1.28, '00177, - 47 to 51 Altitude 'M, '048, 'M,,*7B '$$MØTVU,1ØØ632,5233.737,-1153.8ØØ,7,ØØ18Ø,*Ø832 load_send_data_byte: send_ix = 0 'Load callsign For i = 0 To 5 send_data_byte(send_ix) = data_byte(i) send_ix = send_ix + 1 Next i 'load sentence id 'send_data_byte(7) = "0" 'send_ix = send_ix + 1 'send_data_byte(8) = "," 'send_ix = send_ix + 1 'Load Time For i = 6 To 11 send_data_byte(send_ix) = data_byte(i) send_ix = send_ix + 1 Next i 'add a comma send_data_byte(send_ix) = "," send_ix = send_ix + 1 'Load Latitude For i = 15 To 23 send_data_byte(send_ix) = data_byte(i) send_ix = send_ix + 1 Next i 'Load Longditude If data_byte(36) = 0x57 Then send_data_byte(send_ix) = "-" send_ix = send_ix + 1 For i = 28 To 35 send_data_byte(send_ix) = data_byte(i) send_ix = send_ix + 1 Next i Else 'raw data here Endif 'load number of satellites For i = 40 To 41 send_data_byte(send_ix) = data_byte(i) send_ix = send_ix + 1 Next i 'load altitude For i = 47 To 52 send_data_byte(send_ix) = data_byte(i) send_ix = send_ix + 1 Next i send_ix = send_ix - 1 Return calculate_crc: '----------------------------------------- 'This should be a function '----------------------------------------- crc = 0xffff For i = 0 To send_ix data_word = send_data_byte(i) data_word = ShiftLeft(data_word, 8) 'shift the data left 8 crc = crc Xor data_word 'XOR the data with the CRC For bt = 0 To 7 tmp = crc And 0x8000 'and the CRC with 0x8000 If tmp <> 0 Then 'if this vale <> 0 then will be either 8000 or 0 crc = ShiftLeft(crc, 1) 'shift the CRC left 1 crc = crc Xor polynomial 'XOR the CRC with polynomial Else crc = ShiftLeft(crc, 1) 'else just shift the crc left 1 Endif Next bt Next i Return '------------------------------------------------- 'Procedures '------------------------------------------------- Proc word2nibbles(word1 As Word) Dim temp1 As Word temp1 = word1 And 0x000f n0 = temp1.LB word1 = word1 / 16 temp1 = word1 And 0x000f n1 = temp1.LB word1 = word1 / 16 temp1 = word1 And 0x000f n2 = temp1.LB word1 = word1 / 16 temp1 = word1 And 0x000f n3 = temp1.LB word1 = word1 / 16 End Proc '------------------------------------------------------------- 'Functions '-------------------------------------------------------------- Function nibble2ascii(byte1 As Byte) As Byte nibble2ascii = LookUp("0123456789ABCDEF"), byte1 End Function Function convert_char(chr As Byte) As Byte Call rtty_txbit(0) 'start Bit For j = 0 To 7 'ascii-7 / ascii-8 If chr.0 Then Call rtty_txbit(1) Else Call rtty_txbit(0) Endif chr = ShiftRight(chr, 1) Next j Call rtty_txbit(1) 'stop Bit Call rtty_txbit(1) 'stop Bit End Function Function rtty_txbit(b As Bit) As Bit If b = 1 Then 'High High txcr_pin Else 'Low Low txcr_pin Endif WaitUs 20000 '1/50th of a second = 50 Baud? -20000 End Function 'M = 30873 - 7899 'M0 = 20684 - 50CC
hi C,
What will be the receiving beam pattern for your Base station Yagi aerial.?
ie: beam width in the Horizontal and Vertical planes, at the maximum Range you will expect the remote Rover telemetry link to transmit from to the Base station.?
If you had a +/-5 Deg H and V for example, the arc-tan values could be in a Table in a PIC, say a 18F4520.
E
https://uk.images.search.yahoo.com/search/images;_ylt=A9mSs2zBoWhTdFEAUSlLBQx.;_ylu=X3oDMTB1czE2NGw3BHNlYwNzYwRjb2xvA2lyMgR2dGlkA1VLQzAwMl83Mg--?_adv_prop=image&fr=yfp-t-260-s&va=yagi beam pattern
hi C,
What will be the receiving beam pattern for your Base station Yagi aerial.?
ie: beam width in the Horizontal and Vertical planes, at the maximum Range you will expect the remote Rover telemetry link to transmit from to the Base station.?
If you had a +/-5 Deg H and V for example, the arc-tan values could be in a Table in a PIC, say a 18F4520.
E
https://uk.images.search.yahoo.com/search/images;_ylt=A9mSs2zBoWhTdFEAUSlLBQx.;_ylu=X3oDMTB1czE2NGw3BHNlYwNzYwRjb2xvA2lyMgR2dGlkA1VLQzAwMl83Mg--?_adv_prop=image&fr=yfp-t-260-s&va=yagi beam pattern
Hi C,
Whatever the App, it will have to be a directional aerial so that it can be pointed towards the remote transmitter, if its not directional ie: omnidirectional there is no purpose for a tracking system.
I would strongly advise that you focus on one App and try to avoid the trap of trying to make a universal unit.
E