HSERIN SERIN SERIN2

Status
Not open for further replies.
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
 
hi,
Where did you read that, I often use 4MHz for 9600 or 19200 Baud with no problems.
E

Hi,

I had a quick search for '16F648a baud rate' or something similar, and saw two sites that mention it, but I don't take them too seriously, just note the comments. I could search again if you wish, as I don't know exactly where I saw them.

As there's a signal at the PIC RX, the problem seems to be with the PIC input.

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.?

I attached the GPS to an Oscilloscope, and it outputs 0V-3V, which I think is ok for PIC??? I could see 1second bursts of square wave, even though the GPS LED was not on, so the LED must be monitored for a proper NMEA output.

I've found a MAX232 chip. Checking to see how I connect to a laptop with no serial port, I remembered that I have FTDI programmers. I'm now looking at connecting GPS to FTDI to Laptop, and it looks promising.
 
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.?

I've been round in circles, but now I can see the data on screen in PUTTY, in hindsight, it's not difficult.

I've been watching the data coming in and the strings are typical of NMEA data. I've attached a photo of what's coming from 'this' GPS module, with the actual location removed. I notice that the number of different sentences aren't consistent as I've counted 9 and in the posted image case there's 7. You will notice that there are 2 $GPGSV sentences next to each other, I've counted 4 the same in other instances.

Camerart.
 

Attachments

  • GPS from Module1 FTDI PUTTY data removed.jpg
    70.6 KB · Views: 450
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
 

Attachments

  • AAesp01.gif
    48 KB · Views: 425
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

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.
 
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
 
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

I'm trying to remember not to think of it as satellite information, as it will be used for other things, so if it's ok, can we use SOURCE as a name instead, this will stop me being lulled into a false understanding. I need to research a bit more about this, to see if the simpler $GPGSV can be received from all of the likely SOURCEs.

Cheers, C.
 
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
 

Hi Eric,

It is for aiming aerials at NMEA sources. As I said, I will have to research each of the formats the different sources transmit, in case I have to trim my cloth. If you take an example of a satellite, some of these are weak e,g, Funcubes, and need the aerial aiming towards them for a better signal. If you take one of my multicopters as an example, this also sometimes needs the aerial aiming towards it, especially if it goes behind foliage, also in the case of a multicopter, these send back video, and this is particularly poor at reception, so the receiving aerial is in parallel to the NMEA one. A data source could be an animal, and there are what are called fox hunts, that track a hidden transmitter.

The received signals are picked up via a radio receiver, and this is connected to the tracker though a PIC that commands the two motors on the tracker.

So the tracker is aimed at where the source might be, from previous calculations or knowledge, and once the tracker locks on, the system should take over.

I hope this clarifies things a bit, if not ask some more.

Cheers, C.
 

Attachments

  • TRACKER.jpg
    281.5 KB · Views: 411
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.




I
 

JJW,

That's a pity, I thought things might have just got easier, but it was snatched away

Thanks for the example, and the arctan tip.

Camerart.
 
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
 

Thanks Paul,

I'll print it out and give it a study, Thanks.

Camerart.
 
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
 
Last edited:

Hi E,
From what I understand there are different frequencies for each application, so the aerial/s would be attached to suit that particular one. Once I've got the data input sorted out, then the angles calculation, I'll try to find the speed of the system. The aerial/s will be designed round this. A few tests with simple aerials, then, make them up to suit, this will be last I think, as the aerial receiving angle will need to be within the system speed, but as sensitive as possible.
Camerart.
 
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
 

Hi E,
From what I understand there are different frequencies for each application, so the aerial/s would be attached to suit that particular one. Once I've got the data input sorted out, then the angles calculation, I'll try to find the speed of the system. The aerial/s will be designed round this. A few tests with simple aerials, then, make them up to suit, this will be last I think, as the aerial receiving angle will need to be within the system speed, but as sensitive as possible.

Camerart.

Hi E,

I was hoping to only do this once, so I was trying to make it as universal as possible, at the early stage if possible. My first idea was to aim at my models, but at my amateur radio club they are making trackers that have pre calculated data, and I was hoping to make a 'live' one as something novel, and my thoughts are it would be more immediate and fun too.

I agree about the aerials being directional, and will need to make them to suit.

Edit: If I was forced to only have one SOURCE choice it would be for my models, which use similar GPS modules, that I have connected to Putty. The data will need to be transmitted back. My logic is to see how the tracker works first.

Camerart.
 
Last edited:
hi,
The problem area will be the arctan functions in the PIC.

If you had a directional aerial that had a beam width of 10 degrees, it would mean for a 90 degree quadrant you could use a short Table for the arctan.

So the Table would represent a 90 degree quadrant divided into say 18 sectors [values covering 5 degrees].

Use your Base station as the Datum, so reduce its N, E, to 0,0 and then normalise the received N, E ,GPS data relative to the Dataum 0,0.

This will give a Table pointer for the arctan/ angle.

E
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…