News:

Let's find out together what makes a PIC Tick!

Main Menu

GPS Module Demo Proton Basic Code neo6mv2 - GY-NEO6MV2 - GPS6MV2

Started by dnaci, Feb 06, 2024, 09:45 PM

Previous topic - Next topic

dnaci

neo6mv2 (GY-NEO6MV2)(GPS6MV2) is the code I wrote for the GPS module. GPS and time information are shown on the LCD screen. There is detailed information within the lines of code.

  ' GPS MODULE DEMO CODE: neo6mv2 (GY-NEO6MV2)(GPS6MV2)  www.elektroinfo.org
  '(The module uses serial communication, during the first start-up, provide only voltage (max 5 volts) in an open area for 10 minutes)
  '(Then you can receive the signal somewhere near the window)
'----------------------------------------------------------------------------------------------------------------------------------------------------------------
  'Raw data received from GPS module. These are the values seen in the terminal program when the GPS sensor connection is established
  'with the USB-serial module:
  '$GPRMC,112702.00,A,3946.60705,N,03031.56412,E,0.032,,280819,,,A*73
  '$GPVTG,,T,,M,0.032,N,0.059,K,A*2E
  '$GPGGA,112702.00,3946.60705,N,03031.56412,E,1,08,1.17,793.7,M,37.9,M,,*5C
  '$GPGSA,A,3,27,10,08,32,14,18,20,21,,,,,2.36,1.17,2.05*05
  '$GPGSV,4,1,14,01,13,293,18,04,48,181,21,08,57,292,15,10,52,045,36*7D
  '$GPGSV,4,2,14,11,20,305,19,14,38,157,10,16,06,204,,18,35,302,18*7A
  '$GPGSV,4,3,14,20,26,057,35,21,14,103,27,22,13,245,,24,01,051,*7A
  '$GPGSV,4,4,14,27,64,193,40,32,53,129,39*73
  '$GPGLL,3946.60705,N,03031.56412,E,112702.00,A,A*61
'----------------------------------------------------------------------------------------------------------------------------------------------------------------
   'Additional Information: In the raw data, the number of connected satellites is 8 and the altitude is 793,7 meters above sea level:
   '$GPGGA,112702.00,3946.60705,N,03031.56412,E,1,08,1.17,793.7,M,37.9,M,,*5C
'----------------------------------------------------------------------------------------------------------------------------------------------------------------
    Device = 18F2550
    XTAL = 20
    OPTIMISER_LEVEL=2
    ALL_DIGITAL = true
    Declare FLOAT_ROUNDING = On
    Declare LCD_DTPIN PORTB.4
    Declare LCD_RSPIN PORTB.2
    Declare LCD_ENPIN PORTB.3
    Declare LCD_INTERFACE 4
    Declare LCD_LINES 4
    Declare LCD_TYPE 0
    Declare LCD_COMMANDUS = 2000
    Declare LCD_DATAUS = 50 ' or 255

    'The GPS module is constantly sending information, it is enough to receive this information, you do not need to connect the RX end of the module.
    Declare HSERIAL_BAUD  = 9600       'SERIAL COMMUNICATION SPEED 9600 BAUD, GPS MODULE '9600 BAUD
    Declare HSERIAL_RCSTA = %10010000  'SERIAL PORT IS OPENING AND SETTING TO CONTINUOUS DATA RECEIVING
    Declare HSERIAL_TXSTA = %00100100  'SERIAL PORT TRANSMITTER MODULE IS OPENING - pin:TX1 (portc.7)
    Declare HSERIAL_SPBRG  = 129       'SPRG value given for 20 mhz crystal
    'Declare HSERIAL_SPBRG = 64        'SPRG value given for 10 mhz crystal
    'Declare HSERIAL_SPBRG = 12        'SPRG value given for 8 mhz crystal

    Dim verial As DWord    'INCOMING GENERAL DATA
    Dim GPSSAAT[7] As Byte 'TIME INFORMATION VARIABLE SEPARATED FROM GENERAL DATA
    Dim MESAJ[9]  As Byte  'NORTH EAST COORDINATE SEPARATED FROM GENERAL DATA' INFORMATION VARIABLE
    Dim SAY As Byte        'COUNTER VARIABLE
    Dim SAAT As Byte       'HOUR VARIABLE
    TRISA = %00000001
    TRISB = %00000011
    TRISC = %10000000
    PORTA=0
    PORTB=0
    PORTC=0
    verial = 0
    Cls

    gps_al1:  'BEFORE GPS HOUR DATAS

    HSerIn [verial,skip 5,Str GPSSAAT\12] 'INCOMING DATA GIVES THE 5TH CHARACTER AND THEN THE TIME AND HOUR

    For SAY=0 To 6                        'BY SUBTRACTING 48 FROM THE INCOMING VALUES, THE LCD IS PREPARED FOR CHARACTER DISPLAY
      GPSSAAT[SAY]=GPSSAAT[SAY]-48
    Next

    'GREENWICH 3 HOURS TIME DIFFERENCE CORRECTION CODE FOR TURKIYE
    GPSSAAT[0] = GPSSAAT[0] * 10
    GPSSAAT[1] = GPSSAAT[1] * 1
    SAAT = GPSSAAT[0] + GPSSAAT[1]
    SAAT = SAAT + 3

    If SAAT =24 Then SAAT = 0
    If SAAT =25 Then SAAT = 1
    If SAAT =26 Then SAAT = 2

    'THE TIME IS WRITTEN ON THE LCD:
    Print At 1,1,"HOUR :", " ", #SAAT,":",#GPSSAAT[2],#GPSSAAT[3],":",#GPSSAAT[4],#GPSSAAT[5]
    DelayMS 1700  'this value must be between 1500-1900 ms

    gps_al2: 'GPS 1st coordinate information

    HSerIn [verial,skip 17,Str MESAJ\9] 'INCOMING INFORMATION GIVES NORTH COORDINATES AFTER THE 17th CHARACTER

    'BY SUBTRACTING 48 FROM THE INCOMING VALUES, THE LCD IS PREPARED FOR CHARACTER DISPLAY:
    For SAY=0 To 8
      MESAJ[SAY]=MESAJ[SAY]-48
    Next

    'THE DATA IS WRITTEN ON THE LCD:
    Print At 2,1,"NORTH:"," ", #MESAJ[0],#MESAJ[1],".",#MESAJ[2],#MESAJ[3],".",#MESAJ[5],#MESAJ[6]
    DelayMS 1700  'this value must be between 1500-1900 ms

    gps_al3: 'GPS 2nd coordinate information

    HSerIn [verial,skip 31,Str MESAJ\9]  'INCOMING INFORMATION GIVES NORTH COORDINATES AFTER THE 31th CHARACTER

    'BY SUBTRACTING 48 FROM THE INCOMING VALUES, THE LCD IS PREPARED FOR CHARACTER DISPLAY:
    For SAY=0 To 7
      MESAJ[SAY]=MESAJ[SAY]-48
    Next

    'THE DATA IS WRITTEN ON THE LCD:
    Print At 3,1,"EAST :"," ", #MESAJ[0],#MESAJ[1],".",#MESAJ[2],#MESAJ[3],".",#MESAJ[5],#MESAJ[6]
    DelayMS 1700  'this value must be between 1500-1900 ms
    Cls

    GoTo gps_al1
    End