How do I discern Maidenhead Locator from GPS lat long info.


Closed Thread
Results 1 to 40 of 126

Hybrid View

  1. #1
    Join Date
    Oct 2010
    Posts
    413

    Default Re: How do I discern Maidenhead Locator from GPS lat long info.

    Im from mobile so i will Post a line of the code for the following question when i will be on computer.

    I read the Data from the GPS, especially for the time and date.....
    Serin2.....

    Then i display the needed info......

    Serout2......

    What is the command to use inside the Serout2 in order to jump to a LABEL and Correct the UTC?

    It will be useful if i understand the command inside the Serout2 that give me the access to jump to a LABEL.

    One more question. I see most of You are using the HSERIN2, HSEROUT2,

    And You Richard on your code are using the arrayread arraywrite.

    I need to check the manual and see what is the difference between those.

  2. #2
    Join Date
    Oct 2010
    Posts
    413

    Default Re: How do I discern Maidenhead Locator from GPS lat long info.

    ok i'm stack.

    i place my code up to now. I dont want anyone to write a code for me, i just want from you to give me direction to solve my following problem.

    I know i have many mistakes and maybe i aproach the code in a wrong way, in a difficult direction.

    So one of my problems i would like to solve, is to give the right time, in 24H.

    I have in mind that i need to use interrupts.

    Is there any solution at the moment to use the SEROUT2 command

    Code:
    serout2  lcd,32,[$73,$00,$04,$00,$FF,$E0,"  TIME: ",dec2 hh+3," :",dec2 mm," :",dec2 ss,$00]
    pause 100
    and jump at a label ???

    Code:
    Plusthree:
      hh = hh + 3
      IF hh = 25 THEN hh = 0  
    RETURN
    I would like first to solve time issue, even if i have to refresh/clear the display.....then my next problem to solve is to keep the data on the screen and replace only the numbers or characters needed to be change.

    Following is the code up to now.

    Code:
    '*  Author  : LEONARDO BILALIS                                  *
    '*  Notice  : Copyright (c) 2017 [LEONARDOS BILALIS]            *
    '*          : All Rights Reserved                               *
    '*  Date    : 24/5/2018                                         *
    '*  Version : 1.0                                               *
    '*  Notes   : This is a GPS                          * 
    '*          :                                                   *
    '****************************************************************
    
    @ ERRORLEVEL -306 ; this command prevents the compiler to give you a notice of
                      ; crossing page boundary - make sure bits are set 
    
    @ __config _CONFIG1, _HS_OSC & _WDT_OFF & _LVP_OFF & _CP_OFF
    
    Include "MODEDEFS.BAS"
    DEFINE OSC 8   
    OSCCON=%01111000     '8 Mhz
    CMCON = 7            'turn comparators off
    ANSEL = 0            'All digital
    PORTB = 0            'make low all ports at B range
    input portb.0        'make input portb.0
    
    '-----------------------------------------------------------------------------/
    '                           [ ULCD 1'44 4D System ]                          /
    '---------------------------------------------------------------------------/
    
    ' "o" degree character is manual created for degree value 
    
    '----------------------------------------------------------------------------/
    '                              [ PIC Variables ]                            /  
    '--------------------------------------------------------------------------/
    
    PWRLED      var     PORTb.1   ; this shows that the initialization is finished
    LCD         var     PORTb.2   ; to LCD operation
    GPS_TX      var     PORTb.0   ; info from GPS 
    GPS_RX      var     PORTb.4   ; COMMANDS TO GPS
    Testled     var     PORTb.5 
    dots        var     byte
    dots = 22
    countremain var     byte      ; we use a countremain to check the incoming from portb.0  
    pause 1000
    
    ' --------------------[ GPS Variables for NMEA sentenses ]---------------------/
    '                                                                             /
    '   $GPRMC,090045.000,A,3823.6645,N,02353.3600,E,0.02,195.80,170518,,,A*62   /
    '   $GNGGA,140405.000,3823.6010,N,02353.3054,E,1,9,0.88,0.8,M,35.9,M,,*40   /
    '                                                                          /
    '-------------------------------------------------------------------------/
    Timeout     con     2000
    hh          var     byte    'hours
    mm          var     byte    'minutes
    ss          var     byte    'seconds  
    sss         var     word    'milisecs
    degrees		VAR     BYTE	'latitude/longitude degrees
    minutes		VAR		BYTE	'latitude/Longitude minutes
    minutesD	VAR		word	'latitude/LONGITUDE DECIMAL MINUTES
    dir       	VAR     BYTE   	' direction (latitude: 0 = N, 1 = S / longitude: 0 = E, 1 = W)
    degrees2	VAR     BYTE	'latitude/longitude degrees
    minutes2	VAR		BYTE	'latitude/Longitude minutes
    minutesD2	VAR		word	'latitude/LONGITUDE DECIMAL MINUTES
    dir2        var     byte    ;direction (latitude: 0 = N, 1 = S / longitude: 0 = E, 1 = W)
    SatNo   	VAR		BYTE	'number of satellites connected
    knots       var     word    'speed over ground
    knots2      var     byte    'speed over ground
    course      var     word    'course
    course2     var     byte    'course
    day         var     byte    'day
    month       var     byte    'month
    year        var     byte    'year
    i           var     word    
    GNRMC       var     word    'protocol
    GNGGA       var     WORD    'protocol
    FIX         var     word    'fix sat V/A
    Modefix     var     byte    'mode fix 1 or 2 or 3 depens
    horizon     var     byte
    precision   var     byte
    meter       var     byte
    METERS      var     byte
    Meters2     var     byte
    
    marker2     var     byte    'UTC OR GRT (GREEK TIME)
    
    ' -------------------------------------------------------------------------/  
    '                          [ LCD Initialization ]                         /
    '------------------------------------------------------------------------/
    
    serout2 LCD,32,[$55]      ' uOLED Initialize
    pause 2000
    serout2 lcd,32,[$56,$01]
    pause 1000
    serout2 lcd,32,[$45]      ' clear the lcd
    pause 500
    serout2 lcd,32,[$55]
    pause 500
    serout2 lcd,32,[$45]      ' clesr the lcd
    pause 500
    serout2 lcd,32,[$73,$00,$03,$11,$ff,$ff," Leonardo Bilalis",$00]
    pause 200                       
    serout2 lcd,32,[$73,$02,$06,$10,$ff,"     Copyright 2018",$00]
    pause 3000
    serout2 lcd,32,[$45]
    pause 1000
    serout2 lcd,32,[$73,$02,$06,$10,$ff,$ff,"      GPS.........",$00]
    pause 500
    serout2 lcd,32,[$45]
    pause 200
    
    '----------------------------------------------------------------------/
    '     [ After the lcd initialization we power the Led at PIC ]        /
    '--------------------------------------------------------------------/
    
    HIGH pwrled
    
    
    '----------------------sent a centence to gps------------------------
    
    ;serout gps_rx,84,[$PMTK_103*30]
    pause 100
    
    '-------------------------------------------------------------------/
    '                         [MAIN Program]                           /
    '-----------------------------------------------------------------/
    
    Main: 
    ;gosub clearlcd
    
    serin2 gps_tx,84,[countremain]      ; we check what is coming from the port
    if countremain = 0 then lostcable   ; if nothing is coming the we check the cable
    
    ;gosub clearlcd
    '-------------------------------------------------------------------------------/
    '                                                                              /
    '                    [ Example NMEA Sentense of GNRMC ]                       /
    ' [$GNRMC,090045.000,A,3823.6645,N,02353.3600,E,0.02,195.80,170518,,,A*62]   /
    '                                                                           /
    '--------------------------------------------------------------------------/
    
    serin2  gps_tx,84,[wait("$GNRMC"),_                ;we wait for $GNRMC
    wait(","),dec2 hh,dec2 mm,dec2 ss,wait("."),dec3 sss,_          ;we wait for 090045.000 which is the time when we got the info
    wait(","),fix,_                                                 ;we wait for A
    wait(","),dec2 degrees,dec2 minutes,wait("."),dec4 minutesd,_   ;we wait for 3823.6645
    wait(","),dir,_                                                 ;we wait for N 
    wait(","),dec3 degrees2,dec2 minutes2,wait("."),dec4 minutesd2,_;we wait for 02353.3600
    wait(","),dir2,_                                                ;we wait for E
    wait(","),dec1 knots,wait("."),dec2 knots2,_                    ;we wait for 0.02
    wait(","),dec3 course,wait("."),dec2 course2,_                  ;we wait for 195.80
    wait(","),dec2 day,dec2 month,dec2 year]                        ;we wait for 170518
    
    pause 500
    
    '------------------------------------------------------------------------------/
    '                                                                             /
    '                     [ Example NMEA Sentense of GNGGA ]                     /
    ' [$GNGGA,140405.000,3823.6010,N,02353.3054,E,1,9,0.88,0.8,M,35.9,M,,*40    /           
    '                                                                          /
    '-------------------------------------------------------------------------/
    
    serin2 gps_tx,84,[wait("$GNGGA"),_                              ;we wait for GNGGA
    wait(","),dec2 hh,dec2 mm,dec2 ss,wait("."),dec3 sss,_          ;we wait for 140405.000 which is the time when we got info 
    wait(","),dec2 degrees,dec2 minutes,wait("."),dec4 minutesd,_   ;we wait for 3823.6010 longitude
    wait(","),dir,_                                                 ;we wait for the N/S
    wait(","),dec3 degrees2,dec2 minutes2,wait("."),dec4 minutesd2,_;we wait for 02353.3054 latitude
    wait(","),dir2,_                                                ;we wait for E/W
    wait(","),modefix,_                                             ;we wait for modefix 1,2 or 3 check gps manual for NMEA
    wait(","),dec2 satno,_                                          ;we wait for the number of fixed satellites, this is impoetant info
    wait(","),dec3 horizon,dec precision,_                          ;we wait for horizon
    wait(","),meter,dec2 METERS,dec Meters2]                        ;we wait for the meters 
    
    pause 100
    
    
    '---------------------------------------------------------------------------------/
    ' Here if the GPS module havent been fixed to any satellite will jump to notfix  /
    '-------------------------------------------------------------------------------/
    
    if fix = "V" then notfix                                                        
    pause 100
    
    '-----------------------------------------------------------------------------/
    '                           [ Return from notfix ]                           /
    '                   [ We clear any character on the display ]               /
    '--------------------------------------------------------------------------/
    
    gosub clearlcd
    ;serout2 lcd,32,[$45]
    ;pause 500
    
    
    '--------------------------------------------------------------------------/
    ' here is where the code dispays the stored info from the NMEA sentenses  /
    '------------------------------------------------------------------------/
    
    serout2 lcd,32,[$73,$03,$00,$00,$FF,$FF,"Protocol:","NMEA",$00]
    pause 100
    serout2 lcd,32,[$73,$01,$02,$01,$07,$E0,"Date:",dec2 day,"/",dec2 month,"/",dec2 year,$00]
    pause 100
    serout2  lcd,32,[$73,$00,$04,$00,$FF,$E0,"  TIME: ",dec2 hh+3," :",dec2 mm," :",dec2 ss,$00]
    pause 100
    serout2 lcd,32,[$73,$00,$07,$00,$FF,$FF," Satellites",$00] 
    pause 100
    serout2 lcd,32,[$73,$03,$09,$11,$07,$FF,dec2 satno,$00]
    pause 100
    serout2 lcd,32,[$73,$00,$07,$00,$FF,$FF,"               Fixed",$00]
    pause 100
    serout2 lcd,32,[$73,$0D,$09,$11,$07,$FF,fix,$00]
    pause 100
    serout2 lcd,32,[$73,$00,$0B,$00,$ff,$ff,"Lat : ",dec2 degrees,"*",dec2 minutes,"'",dec4 minutesd," ",dir,$00]
    pause 100
    serout2 lcd,32,[$73,$00,$0D,$00,$ff,$ff,"Lon : ",dec3 degrees2,"*",dec2 minutes2,"'",dec4 minutesd2," ",dir2,$00]
    pause 100
    ;serout2 lcd,32,[$73,$00,$0C,$00,$ff,$ff,"GND SPEED : ",(dec knots,".",dec2 knots2)*/1.852,$00]
    ;pause 200
    ;serout2 lcd,32,[$73,$00,$0E,$00,$ff,$ff,"Meters : ",dec2 METERS,dec Meters2,$00]
    pause 5000
    serout2 lcd,32,[$45]  ' clears the LCD 
    pause 100
    
            goto main
    
    '-----------------------------------------------------------------------------/
    '                              [ SUB ROUTINES ]                              /
    '---------------------------------------------------------------------------/
    
    notfix:     ' Still looking for fixed signal
     
    serout2 lcd,32,[$73,$00,$03,$11,$ff,$ff,"   Waiting for GPS",$00]
    pause 100
    serout2 lcd,32,[$73,$03,$06,$10,$ff," Time:",dec2 hh+3," :",dec2 mm," :",dec2 ss,$00]
    pause 1000
    serout2 lcd,32,[$73,$00,$08,$10,$ff,rep "." \22,$00]
    
    pause 200
    serout2 lcd,32,[$45]  ' clears the LCD 
    pause 100
    
    goto main       'returns to main    
    
    lostcable:
    
    serout2 lcd,32,[$73,$00,$03,$11,$ff,$ff,"   Connection lost",$00]
    pause 100
    serout2 lcd,32,[$73,$01,$06,$10,$ff,"   Please check cable",$00]
    pause 2000
    serout2 lcd,32,[$45]  ' clears the LCD 
    pause 100
    
    goto main
    
    '-------------------------------------------------------------------------/
    '                      GREEK TIME and Correcrion                         /
    '-----------------------------------------------------------------------/
    
    ' at the moment this is not connected to any part of the code
    Plusthree:
      hh = hh + 3
      IF hh = 25 THEN hh = 0  
    RETURN  
    '---------------------------------------------------------------------------/
    '                              [ CLEAR LCD ]                               /
    '-------------------------------------------------------------------------/
    
    Clearlcd:
    serout2 lcd,32,[$45]
    pause 500
    RETURN
    Last edited by astanapane; - 25th May 2018 at 20:56.

  3. #3
    Join Date
    May 2013
    Location
    australia
    Posts
    2,644

    Default Re: How do I discern Maidenhead Locator from GPS lat long info.

    I have found that inline math for lcdout cmd on a pic16 turns to crap, serout2 may have the same issues

    you probably need to do the math first then print result

    i would do it this way

    hh=hh+3 ;utc+3
    hh=hh//24 ;REALLY SHOULD ADD A DAY TO DATE TOO IF day changes
    serout2 lcd,32,[$73,$00,$04,$00,$FF,$E0," TIME: ",dec2 hh," :",dec2 mm," :",dec2 ss,$00]
    pause 100
    Warning I'm not a teacher

  4. #4
    Join Date
    Oct 2010
    Posts
    413

    Default Re: How do I discern Maidenhead Locator from GPS lat long info.

    Hi Richard,

    Thanks for the reply. I will try that.

  5. #5
    Join Date
    Oct 2010
    Posts
    413

    Default Re: How do I discern Maidenhead Locator from GPS lat long info.

    Quote Originally Posted by richard View Post
    I have found that inline math for lcdout cmd on a pic16 turns to crap, serout2 may have the same issues

    you probably need to do the math first then print result

    i would do it this way

    hh=hh+3 ;utc+3
    hh=hh//24 ;REALLY SHOULD ADD A DAY TO DATE TOO IF day changes
    serout2 lcd,32,[$73,$00,$04,$00,$FF,$E0," TIME: ",dec2 hh," :",dec2 mm," :",dec2 ss,$00]
    pause 100
    Richard, really appreciate your help and time.

    Placing the math
    Code:
    hh = hh +3
    hh = hh//24
    before the actual command

    Code:
    serout2  lcd,32,[$73,$00,$04,$00,$FF,$E0,"  TIME: ",dec2 hh," :",dec2 mm," :",dec2 ss,$00]
    it solves the time UTC to local time, and the time when goes at 24 then aytomatically shows 00:

    Now i'm working on that point when time is 23:59:59 at the next second to change the date.

    As i think,it supose to be like that:
    Code:
    if hh = 23 : mm = 59 : ss = 59 
    then DAY = DAY +1
    But then when the Month has only 30 days or 28, we need to specify each month in order to fix the right values and set the parameters.
    Last edited by astanapane; - 26th May 2018 at 14:32.

  6. #6
    Join Date
    May 2013
    Location
    australia
    Posts
    2,644

    Default Re: How do I discern Maidenhead Locator from GPS lat long info.

    if your time offset from utc is 3.00 hours then the minutes and seconds are irrelevant.
    after adding your offset then you need to check if the new hours is >23
    if so then add a day to the date then test if that is greater
    than the number of days for that month [ don't forget leap years / leap centuries],
    then increment the month if there are too many days
    you may even need to increment the year , not forgetting to set the new day/month to the appropriate value after all
    the incrementing and the new hour to modulo 24

    better still get a raspberry pi use python datetime
    now=datetime.datetime.utcnow()+datetime.timedelta( hours=3)
    and it does everything in one line
    Last edited by richard; - 26th May 2018 at 16:24. Reason: fixed datetime
    Warning I'm not a teacher

  7. #7
    Join Date
    Oct 2010
    Posts
    413

    Default Re: How do I discern Maidenhead Locator from GPS lat long info.

    Quote Originally Posted by richard View Post
    if your time offset from utc is 3.00 hours then the minutes and seconds are irrelevant.
    after adding your offset then you need to check if the new hours is >23
    if so then add a day to the date then test if that is greater
    than the number of days for that month [ don't forget leap years / leap centuries],
    then increment the month if there are too many days
    you may even need to increment the year , not forgetting to set the new day/month to the appropriate value after all
    the incrementing and the new hour to modulo 24

    better still get a raspberry pi use python datetime
    now=datetime.datetime.utcnow()+datetime.timedelta( hours=3)
    and it does everything in one line
    ok im trying now to understand your logic which is clear but for me a bit difficult to transfer it to code.

    Lets start.

    if your time offset from utc is 3.00 hours then the minutes and seconds are irrelevant.

    hh = hh +3
    hh = hh//24
    after adding your offset then you need to check if the new hours is >23

    if hh > 23
    At the next sentense i have a difficulty to understand how to write the code.
    if so then add a day to the date then test if that is greater

    DAY = DAY +1
    My understanding is, that when the
    hh > 23
    then with the command
    DAY = DAY + 1
    we see the change only if numerically the Hour goes to 24.

    But we said that hh will not exceed the number 23, after that and correctly will go to 00.

    So i need to find the way to tell the code that every time hh goes to 00 to change the date. And keep the same value until the next change to 00, so the date will change forward again.

    I might need a help here again.

    better still get a raspberry pi use python datetime
    now=datetime.datetime.utcnow()+datetime.timedelta( hours=3)
    and it does everything in one line
    I'm thinking to get either a rasbery pi or arduino pro. I see all amature programmers goes there because coding and labraries are available everywhere.

    I will try to picbasic pro here, but i dont understand why there is no categorized code and libraries available for doing our lifes easier, and with that way we also learn faster.

    anyway as i said in the begging im an amature in programming and is not my main job. I do it on my spare time and i try to make as simple as possible.
    Last edited by astanapane; - 27th May 2018 at 12:41.

  8. #8
    Join Date
    May 2013
    Location
    australia
    Posts
    2,644

    Default Re: How do I discern Maidenhead Locator from GPS lat long info.

    hh = hh +3
    if hh>23 then
    day_added = true
    endif
    hh = hh//24
    .............

    if day_added then
    day = day +1
    if day > numberofdayforthismonth then
    day=1
    month=month +1
    if month >12 then
    month=1
    year=year+1
    endif
    endifendifendifendifendifendif lots of endifs
    Last edited by richard; - 27th May 2018 at 12:46.
    Warning I'm not a teacher

  9. #9
    Join Date
    May 2013
    Location
    australia
    Posts
    2,644

    Default Re: How do I discern Maidenhead Locator from GPS lat long info.

    anyway as i said in the begging im an amature in programming and is not my main job. I do it on my spare time and i try to make as simple as possible
    you may think your way is as simple as possible but its not , its the hardest way by far.
    my way breaks the task up into simple logical blocks , each task can then be solved independently ,and in isolation from the other tasks
    the entire project can be built one task at a time

    task1
    read in nmea scentence
    task2
    verify crc
    task3
    identify scentence type
    task 4
    parse a GPRMC scentence

    task4a
    process a time field

    task4b
    process a LAT field
    task4c
    process a LON field

    .....etc

    simple small steps
    Warning I'm not a teacher

Similar Threads

  1. LAT replaces PORT command?
    By markscotford in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 3rd December 2011, 16:37
  2. Need Info for PBP?
    By azmax100 in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 30th January 2009, 07:44
  3. Replies: 1
    Last Post: - 27th July 2008, 06:14
  4. dmx info.
    By oscar in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 8th May 2005, 11:54

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts