Single chip GPS positioning LCD1602 liquid crystal display latitude and longitude altitude and time date physical production

Publisher:等放假的LwjLatest update time:2019-12-31 Source: 51hei Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

The actual picture produced is as follows:

The microcontroller source program is as follows:

#include "main.h"

#include "LCD1602.h"

#include "GPS.h"


//Define variables

unsigned char KEY_NUM = 0;

bit Page = 0;

unsigned char xdata Display_GPGGA_Buffer[68];

unsigned char xdata Display_GPRMC_Buffer[68];

bit Flag_OV = 0;

bit Flag_Calc_GPGGA_OK = 0;

bit Flag_Calc_GPRMC_OK = 0;


//****************************************************

//Main function

//****************************************************

void main()

{

        unsigned char i = 0;

        Init_LCD1602();

        LCD1602_write_com(0x80); //Pointer setting

        LCD1602_write_word("Welcome to use!");


        Delay_ms(1000);



        Uart_Init();


        while(1)

        {

                Scan_Key();

                if(Flag_GPS_OK ​​== 1 && RX_Buffer[4] == 'G' && RX_Buffer[6] == ',' && RX_Buffer[13] == '.') //Confirm whether the "GPGGA" frame data is received

                {

                        for( i = 0; i < 68 ; i++)

                        {

                                Display_GPGGA_Buffer[i] = RX_Buffer[i];        

                        }

                        Hour = (Display_GPGGA_Buffer[7]-0x30)*10+(Display_GPGGA_Buffer[8]-0x30)+8; //Convert UTC time to Beijing time UTC+8

                                                                                                                                                                                                //0x30 is converted from ASCII to digital

                        if( Hour >= 24) // Overflow

                        {

                                Hour %= 24; //Get the current Hour

                                Flag_OV = 1; //Date carry

                        }

                        else

                        {

                                Flag_OV = 0;

                        }


                        Min_High = Display_GPGGA_Buffer[9];

                        Min_Low = Display_GPGGA_Buffer[10];

        

                        Sec_High = Display_GPGGA_Buffer[11];

                        Sec_Low = Display_GPGGA_Buffer[12];


                        Flag_Calc_GPGGA_OK = 1;

                }


                if(Page == 0 && Flag_Calc_GPGGA_OK == 1)

                {

                        LED1 = ~LED1;

                        Flag_Calc_GPGGA_OK = 0;

                        LCD1602_write_com(0x80); //Set pointer

                        LCD1602_write_data(Hour/10+0x30);

                        LCD1602_write_data(Hour%10+0x30);


                        LCD1602_write_data(':');


                        LCD1602_write_data(Min_High);

                        LCD1602_write_data(Min_Low);


                        LCD1602_write_data(':');

        

                        LCD1602_write_data(Sec_High);

                        LCD1602_write_data(Sec_Low);


                        LCD1602_write_word(" ");

                        

                        LCD1602_write_data(Display_GPGGA_Buffer[54]);        

                        LCD1602_write_data(Display_GPGGA_Buffer[55]);        

                        LCD1602_write_data(Display_GPGGA_Buffer[56]);        

                        LCD1602_write_data(Display_GPGGA_Buffer[57]);

                        LCD1602_write_word("m");

        

                        LCD1602_write_com(0x80+0x40); //Set pointer

                        

                        LCD1602_write_data(Display_GPGGA_Buffer[28]); //N or S


                        LCD1602_write_data(Display_GPGGA_Buffer[17]); //Latitude

                        LCD1602_write_data(Display_GPGGA_Buffer[18]); //Latitude

                        LCD1602_write_data(0xdf); //degrees

                        LCD1602_write_data(Display_GPGGA_Buffer[19]); //Latitude

                        LCD1602_write_data(Display_GPGGA_Buffer[20]); //Latitude

                        LCD1602_write_word("'"); //seconds

                        

                        LCD1602_write_data(Display_GPGGA_Buffer[42]); //E or W


                        LCD1602_write_data(Display_GPGGA_Buffer[30]); //Longitude

                        LCD1602_write_data(Display_GPGGA_Buffer[31]);        

                        LCD1602_write_data(Display_GPGGA_Buffer[32]);        

                        LCD1602_write_data(0xdf);                                                                

                        LCD1602_write_data(Display_GPGGA_Buffer[33]);                        

                        LCD1602_write_data(Display_GPGGA_Buffer[34]);                

                        LCD1602_write_word("'");


                                                

                }

                

                if(Flag_GPS_OK ​​== 1 && RX_Buffer[4] == 'M' && RX_Buffer[52] == ',' && RX_Buffer[59] == ',') //Confirm whether the "GPRMC" frame data is received

                {

                        for( i = 0; i < 68 ; i++)

                        {

                                Display_GPRMC_Buffer[i] = RX_Buffer[i];        

                        }


                        Year_High = Display_GPRMC_Buffer[57];

                        Year_Low = Display_GPRMC_Buffer[58];


                        Month_High = Display_GPRMC_Buffer[55];

                        Month_Low = Display_GPRMC_Buffer[56];


                        Day_High = Display_GPRMC_Buffer[53];

                        Day_Low = Display_GPRMC_Buffer[54];



                        if(Flag_OV == 1) // Carry

                        {

                                UTCDate2LocalDate(); //Convert UTC date to Beijing time                

                        }


                        Flag_Calc_GPRMC_OK = 1;

                }


                if(Page == 1 && Flag_Calc_GPRMC_OK == 1)

                {

                        LED1 = ~LED1;

                        Flag_Calc_GPRMC_OK = 0;

                        LCD1602_write_com(0x80); //Set pointer

                        LCD1602_write_word("20");

                        LCD1602_write_data(Year_High);

                        LCD1602_write_data(Year_Low);

                        LCD1602_write_data('-');

        

                        LCD1602_write_data(Month_High);

                        LCD1602_write_data(Month_Low);

                        LCD1602_write_data('-');

        

                        LCD1602_write_data(Day_High);

                        LCD1602_write_data(Day_Low);

                        

                        

                        LCD1602_write_com(0x80+0x40); //Set pointer

                        LCD1602_write_word("Speed:"); //Display content


                        LCD1602_write_data(Display_GPRMC_Buffer[46]);                

                        LCD1602_write_data(Display_GPRMC_Buffer[47]);                

                        LCD1602_write_data(Display_GPRMC_Buffer[48]);                        

                        LCD1602_write_data(Display_GPRMC_Buffer[49]);        

                        LCD1602_write_data(Display_GPRMC_Buffer[50]);

                        

                        LCD1602_write_word("m/s");                                

                }                

        }

}

//****************************************************

//Convert UTC date to local date

//****************************************************

void UTCDate2LocalDate(void)

{

        Day = (Day_High - 0x30) * 10 + (Day_Low-0x30) + 1; //Day plus one

        Month = (Month_High - 0x30) * 10 + (Month_Low - 0x30);

        Year = 2000 + (Year_High - 0x30) * 10 + (Year_Low - 0x30);

        

        MaxDay = GetMaxDay(Month,Year); //Get the maximum number of days in the month

        if(Day > MaxDay) // overflow

        {

                Day = 1;

                Month += 1;

                if(Month > 12)

                {

                        Year+=1;

                }

        }


        Day_High = Day/10 + 0x30; //Convert date value to ASCII

        Day_Low = Day%10 + 0x30;


        Month_High = Month/10 + 0x30; //Convert month value to ASCII

        Month_Low = Month%10 + 0x30;


        Year_High = Year%100/10 + 0x30; //Convert year value to ASCII

        Year_Low = Year%10 + 0x30;                        

}


//****************************************************

//Get the maximum value of the date in the month

//****************************************************

unsigned char GetMaxDay(unsigned char Month_Value,unsigned int Year_Value)

{

        unsigned char iDays;

        switch(Month_Value)

        {

                case 1:

                case 3:

                case 5:

                case 7:

                case 8:

                case 10:

                case 12:

                        {

                                iDays = 31;

                        }

                        break;

                case 2:

                        {

                                // February is special. It is necessary to determine whether the month has 28 or 29 days based on whether it is a leap year.

                                iDays = IsLeapYear(Year_Value)?29:28;

                        }

                        break;

                case 4:

                case 6:

                case 9:

                case 11:

                        {

                                iDays = 30;

                        }

                        break;

                default : break;

        }

        return(iDays);                                                

}


//****************************************************

// Leap year detection

//****************************************************

bit IsLeapYear(unsigned int uiYear)

{

……………………


Reference address:Single chip GPS positioning LCD1602 liquid crystal display latitude and longitude altitude and time date physical production

Previous article:Program for making a microcontroller tracking car
Next article:A complete design of a heart rate tester made with a single chip microcomputer and st188

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号