Implementation of GPS Precision Clock Extraction Based on PIC18F8520

Publisher:真情相伴Latest update time:2011-08-16 Keywords:PIC18F8520 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

GPS (Global Positioning System) is the most complete satellite navigation system in the world. It not only has the real-time, continuous and high-precision three-dimensional positioning capability covering the whole world, but also has the precise timing function. Using highly stable and precise satellite-borne atomic clocks as signal sources for time transmission and comparison has become an important means of obtaining time in many fields. Based on this, this paper uses the precise timing function provided by GPS and adopts single-chip microcomputer technology to realize a GPS clock, and displays the time information through LCD.

System composition and hardware implementation

1 System Configuration

The GPS clock system mainly consists of three parts: GPS receiver, single chip microcomputer and LCD display, as shown in Figure 1.

GPS clock system block diagram

Figure 1 GPS clock system block diagram

GPS Receiver

In this system, the GPS receiver uses Garmin's GPS15XL, which is a 12-channel GPS receiver with small size, light weight, low power consumption, short first positioning and recapture time, strong anti-blocking and anti-interference capabilities, extremely stable and reliable performance, simple operation and easy development. It can work in the voltage range of 3.3~5.4V, and this system uses +3.3V power supply; the precision of the precision timing type can reach ±50ns (typical value); it has a serial port, the output is RS232, the input can be RS232 or TTL level with RS232 polarity, the baud rate is optional from 300 to 38 400, the default is 4800, no parity check, 8 data bits, 1 start bit, and 1 stop bit. The data output by GPS15XL is based on the NMEA0183 ASCII code interface protocol of the National Marine Electronics Association of the United States, and can output multiple sentences, including longitude, latitude, speed, azimuth, altitude, world time, ephemeris and other information. It can also output Garmin binary format information. It is very suitable for vehicle navigation, maritime navigation, power system time calibration, etc.

The configuration of GPS15XL can be implemented in the program using the microcontroller through NMEA 0183 statements, or it can be done using the SNSRCFG software. The configuration parameters will be saved in the permanent memory and will automatically take effect the next time the power is turned on. To simplify the design, this article adopts the second method, that is, to initialize the configuration of GPS15XL through the SNSRCFG software.

GPS15XL can output two time signals: one is the absolute time (year, month, day, hour, minute, second) of UTC (Coordinated Universal Time) contained in the serial port output information; the other is the synchronization pulse signal 1PPS with an interval of 1s, and the synchronization error between the pulse leading edge and UTC does not exceed 1μs. This system mainly uses the NMEA 0183 sentence output by the serial port to obtain UTC time information.

NMEA 0183 sentences start with a "$" and end with , which ends with the ASCII characters "Carriage Return" (hexadecimal 0D) and "Line Feed" (hexadecimal 0A). The following uses the GPRMC statement used in this article as an example to illustrate its format:

$GPRMC,<1>,<2>,<3>,<4>,<5>,<6>,<7>,<8>,<9>,<10>,<11>,<12> *hh

$GPRMC: Sentence start flag (Recommended Minimum Specific GPS/TRANSIT Data recommended positioning information)

<1> UTC time, hhmmss (hours, minutes, seconds) format

<2> Positioning status, A = valid positioning, V = invalid positioning

<9>UTC date, ddmmyy (day month year) format

The final check code *hh is used for parity check, which is usually not necessary, but it is recommended to use the check code when there is strong electromagnetic interference in the surrounding environment. hh represents the bitwise XOR value of all characters between "$" and "*" (excluding these two characters).

PIC18F8520

The system uses the high-performance RISC CPU PIC18F8520 produced by Microchip as the controller. It has 32KB of FLASH program memory, 2KB of SRAM data memory, and 1KB of EEPROM data memory. The computing speed can reach 10MIPS. It can work within the clock frequency range of DC to 40MHz. It has a USART interface, supports RS-485 and RS-232, and can be connected to the GPS module to obtain time information. It supports ICSP online serial programming to facilitate software upgrades and maintenance. It supports ICD, which allows online debugging and shortens the development cycle.

LCD Display

The system uses LCD1602 as the display device. LCD1602 liquid crystal display module has the advantages of small size, low power consumption, rich display content, ultra-thin and light, and is widely used in pocket instruments and low-power application systems. It can display two lines, 16 characters per line, powered by a single +5V power supply, simple peripheral circuit configuration, low price, and high cost performance.

2 Hardware Circuit

The hardware circuit of the system is shown in Figure 2 and Figure 3.

MCU peripheral circuit connection

Figure 2 MCU peripheral circuit connection

Connection between microcontroller and GPS module

Figure 3 Connection between MCU and GPS module

There are two voltages on the circuit board: 3.3V and 5V. The LCD is powered by 5V, while the microcontroller and MAX3232 work at 3.3V. The external power supply is 5V, which is converted to 3.3V by AS2830 to power the microcontroller and MAX3232. As can be seen from Figure 2, the power pin of the microcontroller is not directly connected to 3.3V, but can be connected to 3.3V or VDD through the J2 and J3 jumpers. This is because the microcontroller is powered by MCD2 when the PIC16-MCD2 programmer is used for online programming through the ICSP interface. At this time, the power pin of the microcontroller needs to be connected to VDD (the output voltage VDD of MCD2 is 5V); while during normal operation, the microcontroller is powered by the circuit board, and the J2 and J3 jumpers are connected to 3.3V. The microcontroller works at 3.3V, which can reduce power consumption.

PIC18F8520 has both analog power and analog ground pins as well as digital power and digital ground pins. In circuit design, the analog power and digital power are separated, and the analog ground and digital ground are separated. The analog power and digital power are connected through magnetic beads, and the analog ground and digital ground are connected at a single point through a 0Ω resistor to avoid interference between analog signals and digital signals and improve system reliability.

Software Implementation

The software consists of a main program and an interrupt subroutine, and is implemented in C language using the MPLAB C18 compiler under the MPLAB IDE v8.53 environment.

The system is initialized, data is processed, and LCD is displayed in the main program. The reception of GPS data is realized through serial port interruption. Every time a complete NMEA sentence is received, a flag is set. The main program extracts the UTC time and converts it into Beijing time by querying the flag, and then displays it on the LCD. Since the complex data processing is placed in the main program, the interrupt program can be kept as short as possible. When other interrupts occur, the microcontroller can respond in time, improving the real-time performance of the system. The flow chart is shown in Figure 4.

flow chart

flow chart

Figure 4 Flowchart

Since the time output by the GPS module is UTC time, it needs to be converted into local time (Beijing time) according to custom. This work is completed in the main program. According to local time = UTC time + time zone value, and Beijing is located in the 8th time zone, the time zone value is +8, so Beijing time = UTC time +8. In the conversion process, the UTC time of 16:00:00-23:59:59 must be processed accordingly. After +8, it is determined whether the hour is greater than 24. If it is greater, 24 is subtracted, and the date is +1. In addition, it also involves the processing of leap years, long months, and short months.

In the interrupt service program flow chart, when the serial port receives data, it judges the prefix and only judges the character "$". This is because the GPS15XL has been set to only output one NMEA sentence, GPRMC, through the SNSRCFG software.

Debugging and running

First, initialize GPS15XL. Connect GPS15XL to PC through serial port, power on GPS15XL, set initialization information with SNSRCFG software, set baud rate to 9600, output only one GPRMC statement (one GPRMC statement is enough to get UTC date and time), write this information into permanent memory in OEM board, and it will automatically take effect when powered on next time.

Then, use the PIC16-MCD2 programmer to write the compiled program into the microcontroller through the ICSP interface reserved on the circuit board. When programming, do not power the circuit board. The microcontroller is powered by MCD2. Pay attention to the setting of the jumper on the circuit board.

Finally, connect GPS15XL to the circuit board. Power on the circuit board and GPS15XL, and the timing receiving system enters normal working state. The microcontroller receives satellite data from GPS15XL through RS-232 serial mode, obtains accurate time information, converts it into Beijing time, and displays it on the LCD.

Note: When in use, the GPS timing antenna must be placed in an open outdoor area, otherwise it will not be able to receive satellite signals and obtain UTC time information.

Conclusion

This paper uses PIC18F8520 to extract GPS high-precision clock and display it on LCD. The implemented clock system is part of the distribution line fault remote monitoring and positioning system project. After testing, the design runs stably and can provide accurate time information for the entire system with high reliability, accuracy and practicality.

Keywords:PIC18F8520 Reference address:Implementation of GPS Precision Clock Extraction Based on PIC18F8520

Previous article:Design of portable magnetic memory detector based on PIC microcontroller
Next article:The software and hardware design of ultrasonic tooth cleaning machine based on single chip microcomputer

Recommended ReadingLatest update time:2024-11-16 16:34

Design of serial communication system between FPGA and GPS-OEM board
0 Introduction The Global Positioning System (GPS) is the second generation satellite navigation system of the United States. It was developed on the basis of the Transit satellite navigation system. GPS can provide all-weather, continuous, real-time high-precision navigation parameters, can achieve three-d
[Embedded]
Design of serial communication system between FPGA and GPS-OEM board
Analysis of Important Performance Indicators of GPS
This article mainly introduces some important performance indicators of GPS. 1. What is a satellite trajectory? The GPS global positioning navigation system has 24 GPS satellites orbiting the earth along six orbits (four in each group). Generally, there will be no more than 12 satellites on the same si
[Analog Electronics]
A method for testing GPS antenna of intelligent terminal
Abstract: With the popularization of smart phones, Global Positioning System (GPS) has become an essential function for smart terminals to support navigation, positioning and other services. Since GPS uses satellite communication technology, its downlink power signal is lost through the atmosphere and other environmen
[Test Measurement]
A method for testing GPS antenna of intelligent terminal
Tesla Model S/3 vulnerable to GPS spoofing attacks, says Israeli cybersecurity firm
According to foreign media reports, recent research by Israeli cybersecurity company Regulus Cyber ​​shows that the navigation systems of Tesla Model S and Model 3 electric vehicles are vulnerable to cyber attacks. Regulus Cyber ​​recently test-drove a car with the Tesla Navigate on Autopilot function activated and fo
[Automotive Electronics]
Tesla Model S/3 vulnerable to GPS spoofing attacks, says Israeli cybersecurity firm
STM32F103 decodes the NMEA data transmitted back by the GPS module
1. Serial port redirection, which implements the bottom layer to directly call printf scanf and other functions to redirect to the corresponding serial port operation. 2. Serial port interrupt receiving function, serial port DMA transfer function. 3. The SD card is mounted with FatFs file system, and the SD card is re
[Microcontroller]
STM32F103 decodes the NMEA data transmitted back by the GPS module
Discussion on the technical roadmap for the development of vehicle-mounted GPS navigation system in my country
GPS , or Global Positioning System, is a radio navigation and positioning system based on 24 global positioning satellites that provides three-dimensional position, three-dimensional speed and other information to all parts of the world around the clock. At present, GPS technology has develop
[Automotive Electronics]
The Assisted Global Positioning System (A-GPS) Revolution and Its Consumer Market
Abstract: Currently, seven key technologies have enabled GPS to enter mobile phones around the world. This article details the entry process of these technologies and what impact they will have in the next 10 years. Ten years ago, the E911 Act initiated the first successful milestone of consumer
[Security Electronics]
The Assisted Global Positioning System (A-GPS) Revolution and Its Consumer Market
Design and implementation of GPS vehicle terminal based on single chip microcomputer
The command and dispatch of police vehicles, the monitoring and safety dispatch of cash transport vehicles, the operation and management of taxis and reasonable dispatch have become increasingly important issues in the public security, banking and public transportation systems. The emergence of GPS global positionin
[Industrial Control]
Design and implementation of GPS vehicle terminal based on single chip microcomputer
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号