Using signals from GLONASS/GPS navigation systems to correct the readings of a digital magnetic compass

The article describes the results obtained from research, manufacture and quality improvement of an inexpensive digital magnetic compass system. Given that the receivers of the global navigation satellite systems (GNSS) signals are not expensive, in order to increase the accuracy and reliability of the compass, in this paper, the authors propose a method to use the signal of the GNSS global positioning system to compare and adjust the azimuth value of the Digital magnetic compass (DMC).


Introduction
The magnetic compass system on ships is very important [1][2]. During the voyage, based on the compass system, the operator knows the direction and ensures steady movement along the optimal trajectory, along the shortest distance. On large ships, complicated and very expensive electronic compass systems are use. The operation and repair of these systems are very complicated. Therefore, a low-cost Digital magnetic compass system is proposed, characterized by high performance fully complying with the standards of the International Maritime Organization (IMO), which is of great importance.
Today, satellite navigation technology is developing very strongly. Many manufacturers have produced many types of satellite receivers with low cost but high accuracy. The global navigation satellite system GNSS is designed to determine the location, speed, and the exact time of sea, air, land and other types of consumers. NAVSTAR and GLONASS are dual-purpose systems, originally developed on the order and under the control of the military for the needs of the Ministries of Defense and therefore the first, and main purpose of the systems is strategic, the second purpose of these systems is civil. Satellite navigation system is widely used in areas such as aviation, sea, geodesy, etc. [3][4][5]. In the article, the authors describe the results of research and manufacture of a digital magnetic compass system and propose a method for using the signal received from the GPS positioning sensor to correct the readings of the DMC of the system.

Structural scheme of Digital magnetic compass system
The Digital magnetic compass system is made up of the devices shown in Figure 1. The system includes:

GNSS receiver
This device is responsible for receiving signals from the GNSS system and then exports data NMEA0183, this data contains the coordinates of the receiver. To receive GPS signals, the authors use the GPS-NEO7 sensor [6]. This is a sensor that receives GPS signals from satellites and then exports NMEA data that contains longitude and latitude values. The microcontroller inside the DMC reads this data and performs calculations to obtain the azimuth of the Ship.

Digital Magnetic Compass (DMC)
The compass system has an equivalent function as an electronic compass. This device collects the magnetic fields of the Earth, and then the microcontroller ATMEGA128 inside the device uses the Kalman filter algorithm to process and obtain the most accurate directional signal. At the same time, the internal microcontroller of the DMC also receives the NMEA0183 signal from the GPS-NEO07 positioning sensor and calculates the azimuth angle based on this positioning signal. Finally, the microcontroller encapsulates the 2 azimuth values received from the HMC5883 module and the GPS-NEO07 sensor in 2 different coded data packets. A data packet containing the azimuth value of the HMC5883 module is encoded as NMEA0183 standard transmitted for display on devices within the system [7]. The data packet contains azimuth values from a separately encoded GPS sensor and is transmitted to a computer for receiving and displaying. The purpose of using a computer is to visualize between the two azimuth values from the GPS sensor and the HMC5883 module, which provides appropriate comments and corrections.

Digital GyroRepeater
This device has the function of displaying the direction and speed of rotation of the Ship, and the parameters are displayed on eight 7-segment LED displays. The ship's data direction angle comes from the DMC in the form of NMEA0183 packets. The advantages of this device are user-friendliness, easy installation and simple use.

Gyrocompass Repeater
This device is used to display the heading of the vessel in the form of rotating needles. The input NMEA0183 data comes from the DMC. The advantages of this device are its strength, aesthetics and the ability to withstand harsh external conditions. The disadvantage of this device is that it is made entirely of metal, which makes it difficult to manufacture and expensive.

RS485-NMEA Buffer
This device is used to receive the NMEA0183 data from the DMC, then amplifies and transmits NMEA0183 data to various display devices. The buffer device has one input and several terminals for joint interfacing with the marine equipment.

Power supply 24VDC
The 24VDC power supply is used to power the entire system. To ensure efficient operation of the system, the supply current is greater than 2A.

USB485 converter and computer
The USB485 converter and computer has the function of collecting encoded NMEA0183 data containing the azimuth value obtained from the GPS-NEO7 sensor calculation. The azimuth value obtained from calculating data from the GPS-NEO7 sensor is visually displayed on a computer using C # software. The display of two azimuth values on computers and devices in the system allows users to compare and evaluate the measurement results obtained using a magnetic sensor and a GPS receiver.

Result of manufacturing device DMC
The result of manufacture of DMC device is shown in Figure 2. Inside this device is the HMC5883 magnetic field sensor module. This is a special module that is commonly used in devices such as cell phones, navigation devices, etc. [8][9]. The microcontroller ATmega128 inside the device continuously reads the data inside the HMC5883 module, and then uses the Kalman filter algorithm to obtain the accurate heading angle value. The microcontroller inside the DMC in the same way receives location data from the GPS receiver through the UART serial port. NMEA0183 data from the GPS sensor is read continuously, and the microcontroller processes this data. The GPS data processing algorithm is described in section 4 of this article. The 485 chip inside the device converts the TTL NMEA0183 data of the microcontroller into a two-wire signal, which is then transmitted to other devices. The purpose of using 485 chips is to increase the transmission distance and eliminate interference during data transmission.

Designing and Manufacturing a digital gyro repeater
The result of designing and manufacturing is shown in Figure 3. Inside this device is a microcontroller, which is the central processor. The microcontroller continuously reads NMEA0183 data output from the DMC, processes and displays the value of the ship's heading angle using four 7-segment LEDs. Inside the device, four additional 7-segment LEDs are also used to display the speed of the ship's rotation. There are two buttons for adjusting the brightness of the LED and for resetting the device. Inside this device, a Max485 chip is used to receive the NMEA0183 data from the digital magnetic compass. The microcontroller reads and processes the packet,then finally displays the parameters on the corresponding LEDs.

Designing and Manufacturing a Gyrocompass Repeater
The appearance of the manufactured unit is shown in Figure 4. The control center of this device is the ATmega8 microcontroller [10]. The microcontroller receives NMEA0183 data measured by the digital magnetic compass, processes them and generates electrical pulses to control the stepper motor. To control the stepper motors, the gear ratios of the drive are taken into account. The advantages of this device are the convenience of observation, accuracy, water resistance and the ability to withstand extreme marine conditions. In the control unit of this device, there is a button for resetting and synchronizing the drive. Upon pressing this button, the needle of the angle indicator is set to 0 degree for a new cycle to begin. In the control unit of this device, there is also a potentiometer that regulates the brightness of light on the surface of the rotary index. While monitoring the device at night, it allows users to adjust the brightness.

Designing the NMEA0183 signal buffer
This device has the function of connecting the devices of the system together. The NMEA 0183 data received from the DMC is amplified and transmitted to various devices. The result of the NMEA0183 signal buffer design is shown in Figure 5.

A method suggested for adjusting the readings of the DMC based on the GNSS positioning signal
To improve the accuracy of the DMC, the author used the signal of the global positioning system of GNSS to improve the accuracy of the DMC. Receiving GNSS signals is very simple with a GPS receiver. The receiver transmits NMEA0183 data containing the longitude and latitude values. The GPS sensor in the article uses Ublox NEO7. This sensor is compact and highly sensitive, supports most GPS protocols, and is suitable for integration into a printed circuit board device. The GPS sensor of the receiver is fixed on the ship. The image of the sensor is shown in Figure 6.  The ship azimuth calculation function based on the GPS receiver sensor is valid only when the ship is moving. This method cannot be used when the ship is standing still. Supposing that the ship moves from position A1 to A2 (Fig. 7). Azimuth Ɵ of the ship is determined by formula 1 [11].
In formula 1, Ɵ is the value of the azimuth angle to be calculated (Compared to the north direction of the Earth), 2 parameters ∆lat and ∆lon are determined according to formula 2 and 3 In Equations 2 and 3, the parameters lonA, latA, lonB and latB are the latitude and longitude of the ship at 2 points A1 and A2. According to the formula 1, 2 and 3, the azimuth of the ship is calculated 2 times in a row. In the process of ship movement, GPS receivers continuously receive signals from satellites and export NMEA data packets containing the longitude and latitude values of the ship at this time. The microcontroller inside the magnetic compass is programmed to read the NMEA data of the GPS receiver, then separate the longitude and latitude data in the data message and calculate the azimuth value in accordance with formula 1, 2 and 3. To improve the measurement accuracy, the distance traveled between two measurements should be large (size from 0.8 to 4 m).
After completing the ship azimuth calculation based on the GNSS signal using the formulas 1, 2 and 3, finally, the microcontroller inside the DMC transmits two different encoded NMEA0183 data packets to the computer and devices within the system. A computer with a function to display the azimuth value from the GPS sensor and devices displayed inside the system display the azimuth value obtained from the HMC5883 module. 2 packets of data transmitted from ATMEGA128 microcontroller in the form of '$HEHDT,XXX.X,T*YY' and '$GPS,ZZZ.Z,'. 5 characters XXX.X is the azimuth value obtained from the HMC5883 module, and 5 characters ZZZ.Z is the azimuth obtained from calculating the data from the GPS sensor. Other characters in the two data packets are used to encode the differences between them. Program algorithm of device DMC is shown in Figure 8.   After loading the program for ATMEGA128 microcontroller. Compass DMC is tested practically under a ship. The authors use personal computers to connect to DMC to display the results. In Figure 9, the results are obtained in the case of a 225-degree azimuthal motion. From the experimental results show that combining magnetic modules and GPS positioning sensors will increase the accuracy for DMC. a. Only use HMC58883 module b. HMC5883 module + Positioning sensor NEO-7M

Conclusions
The article describes the results of research and development of a Digital magnetic compass system. The authors have also proposed methods of using signals of GNSS system to improve and increase the quality of equipment DMC in the system. The equipment in the system is distinguished by high aesthetics, developed in accordance with technical standards. The experimental results show that the use of HMC5883 magnetic module combination and NEO07 GPS sensor will increase accuracy for DMC compass.