SwingeyP
Member
Hello again,
First of all thanks to everyone that has helped me with this project.
I am still having a few problems but i'm much futher forward.
The RTTY side of the code has been working for some time and so I decided to add the GPS bit.
The code works just fine under simulation well appears to any way but in the real world things go bad.
--- SIMULATION
I have reduced the characters sent and the loops. It still takes a while to run n the simulator so stay with it.
I have the Hardware Uart open - you will see ryry and then the code waits for something from the GPS. send it ghghghg or some other rubbish dont forget 0x0d for cr. The first character is checked if its not a $ then get data again. Enter same string again - code will drop out from here and send ryry again. (error trap so it doesn't just sit there)
Once ryry is sent again the code waits for something from GPS. Enter $GPGGA,,,,,,0,,,,,,,,*66
again add 0x0d (code will wait for it). This time the code fills the array and checks to see if fild 12 is "0". If it is then we don't have any satellites as yet. Report this and return to start. If field 12 isn't a "0" then this is a valid packet. Send the time data. Then do it all again.
All seems to work just fine.
--- Real World
In the real world however the error_catch never 'catches' (i assume) and after M0TVU RTTY TEST BEACON is sent 4 times thats it. It just sits there doing nothing.
The GPS is pulsing every second and I am monitoring it's output so I know it's there.
Can anyone see
1) whay the error_catch doesn't work
2) why I don't ever seem to see any GPS data
Thanks for all the help it's really appreciated.
Regards - Paul
First of all thanks to everyone that has helped me with this project.
I am still having a few problems but i'm much futher forward.
The RTTY side of the code has been working for some time and so I decided to add the GPS bit.
The code works just fine under simulation well appears to any way but in the real world things go bad.
--- SIMULATION
Code:
'- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -
'RTTY with NTX2 Test written by paul swingewood
'March 2013 - PIC 16F628A
'Based on code developed by Rob Harrison for Arduino
'--------------------------------------------------------------------------
'Define SIMULATION_WAITMS_VALUE = 2
'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
Define CONF_WORD = 0x3f50 'Internal Oscillator'
Define CLOCK_FREQUENCY = 4
AllDigital
Define SEROUT_DELAYUS = 1000
Symbol txcr_pin = PORTA.7
Dim i As Byte 'used for loops
Dim j As Byte 'used for loops
Dim ch As Byte 'used to hold individual character
Dim times_sent As Byte 'used to check number of times sent before waiting
Dim gpsin(70) As Byte 'Array
Dim inx As Byte
Dim x As Byte
Dim error_catch As Byte
startup:
Hseropen 4800
times_sent = 0
start:
For i = 0 To 1 '22
ch = LookUp("RY"), i 'M0TVU RTTY TEST BEACON
Hserout ch
Call convert_char(ch)
Next i
ch = 13 'Carriage Return
Call convert_char(ch)
If times_sent = 1 Then '4
'---------------- READ THE GPS INFO
error_catch = 0
read_gps:
ch = "x" 'anything other than 0x0d - cr
'Read the data coming back from the URM37'Hserin datain(0) 'Bit1 -14
Hserin gpsin(0)
If gpsin(0) = "$" Then
'load the string into the gpsin array
inx = 1
While ch <> 0x0d 'keep load characters until yo see cr
Hserin ch
gpsin(inx) = ch
inx = inx + 1
Wend
If gpsin(12) = 0x30 Then 'ascii 0 - No Satelites found
For i = 0 To 1 '15
ch = LookUp("No"), i 'No Satellite Fix
Hserout ch
Call convert_char(ch)
Next i
times_sent = 0
Goto start
Else
Gosub send_time
'Gosub show_north
'Gosub show_west
'Gosub show_alt
times_sent = 0
Goto start
Endif
Else
If error_catch < 2 Then
error_catch = error_catch + 1
Goto read_gps 'do this until you see the $
Else
Goto start
Endif
Endif
Endif
times_sent = times_sent + 1
Goto start
End
send_time:
For x = 7 To 14
ch = gpsin(x)
Hserout ch
Call convert_char(ch)
Next x
Return
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 2 '1/50th of a second = 50 Baud? -20000
End Function
I have the Hardware Uart open - you will see ryry and then the code waits for something from the GPS. send it ghghghg or some other rubbish dont forget 0x0d for cr. The first character is checked if its not a $ then get data again. Enter same string again - code will drop out from here and send ryry again. (error trap so it doesn't just sit there)
Once ryry is sent again the code waits for something from GPS. Enter $GPGGA,,,,,,0,,,,,,,,*66
again add 0x0d (code will wait for it). This time the code fills the array and checks to see if fild 12 is "0". If it is then we don't have any satellites as yet. Report this and return to start. If field 12 isn't a "0" then this is a valid packet. Send the time data. Then do it all again.
All seems to work just fine.
--- Real World
Code:
'- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -
'RTTY with NTX2 Test written by paul swingewood
'March 2013 - PIC 16F628A
'Based on code developed by Rob Harrison for Arduino
'--------------------------------------------------------------------------
'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
Define CONF_WORD = 0x3f50 'Internal Oscillator'
Define CLOCK_FREQUENCY = 4
AllDigital
Define SEROUT_DELAYUS = 1000
Symbol txcr_pin = PORTA.7
Dim i As Byte 'used for loops
Dim j As Byte 'used for loops
Dim ch As Byte 'used to hold individual character
Dim times_sent As Byte 'used to check number of times sent before waiting
Dim gpsin(70) As Byte 'Array
Dim inx As Byte
Dim x As Byte
Dim error_catch As Byte
startup:
Hseropen 4800
times_sent = 0
start:
For i = 0 To 22 '22
ch = LookUp("M0TVU RTTY TEST BEACON"), i 'M0TVU RTTY TEST BEACON
Call convert_char(ch)
Next i
ch = 13 'Carriage Return
Call convert_char(ch)
If times_sent = 4 Then '4
'---------------- READ THE GPS INFO
error_catch = 0
read_gps:
ch = "x" 'anything other than 0x0d - cr
'Read the data coming back from the URM37'Hserin datain(0) 'Bit1 -14
Hserin gpsin(0)
If gpsin(0) = "$" Then
'load the string into the gpsin array
inx = 1
While ch <> 0x0d 'keep load characters until yo see cr
Hserin ch
gpsin(inx) = ch
inx = inx + 1
Wend
If gpsin(12) = 0x30 Then 'ascii 0 - No Satelites found
For i = 0 To 15 '15
ch = LookUp("No Satellite Fix"), i 'No Satellite Fix"
Call convert_char(ch)
Next i
times_sent = 0
Goto start
Else
Gosub send_time
'Gosub show_north
'Gosub show_west
'Gosub show_alt
times_sent = 0
Goto start
Endif
Else
If error_catch <= 2 Then
error_catch = error_catch + 1
Goto read_gps 'do this until you see the $
Else
times_sent = 0
Goto start
Endif
Endif
Endif
times_sent = times_sent + 1
Goto start
End
send_time:
For x = 7 To 14
ch = gpsin(x)
Call convert_char(ch)
Next x
Return
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
In the real world however the error_catch never 'catches' (i assume) and after M0TVU RTTY TEST BEACON is sent 4 times thats it. It just sits there doing nothing.
The GPS is pulsing every second and I am monitoring it's output so I know it's there.
Can anyone see
1) whay the error_catch doesn't work
2) why I don't ever seem to see any GPS data
Thanks for all the help it's really appreciated.
Regards - Paul