Docsity

Digital Compass Using Arduino, Papers of Embedded Systems

Toggle sidebar
bg1
1
Digital Compass Using Arduino
Phuc Le Xuan1, Duy Nguyen Tien2
1 Bach Khoa University, Affiliation 1, Ho Chi Minh City, Vietnam
2 Bach Khoa University, Affiliation 1, Ho Chi Minh City, Vietnam
Abstract— Human, for a long time, have been using a
compass for applying in navigation. As information gathering
becomes critical nowadays, it is necessary to have the tools to
collect information about the environment. Orientation is key
to understanding our location and interpreting data from that
environment. The most reliable form of the determining
orientation is through measurement of Earth’s magnetic field.
In this paper, we will discuss how to design a digital compass
using the magnetic sensor board and processing with the
microcontroller on Arduino UNO board.
Keywords— Digital compass, Arduino, Magnetic sensor
board, LCD, Independent Vcc Source.
I. INTRODUCTION
Digital compasses have become popular in the past few
years due to the advancement of magnetic sensors and
feature-rich microcontroller. Compass applications have
increased from simple, hand-help navigation devices to
automobile navigation systems with voice recognition and
up-to-date global maps.
The digital compass is implemented via the
Atmega328P-AU [3] microcontroller on an Arduino board
and HMC5883L [2] sensor board... The values of magnetic
field sending to the Arduino, where these values are
mathematically processed to find the heading angle in
degree which is the location of the North in degrees. The
result then displayed on a Nokia 5110 LCD [4].
II. OVERVIEW
A. Compass Theory Basics
Basically, to define one compass, we need three angles
term these are popular within aviation industry: Heading,
Pitch, and Roll. These angles are always referenced to the
horizontal plane, which is perpendicular to Earth’s
gravitational force. Where:
Heading: the angle in the horizontal plane measuring
clockwise from a true north direction (1o to 360o).
Pitch: the angle between an aircraft’s longitude axis
(tail to nose) and the horizontal plane. For example, if
the nose of the aircraft is pointed up, the pitch angle is
positive.
Roll: the angle about the longitude axis between the
horizontal plane and the actual flight orientation. For
example, if the right wing of the aircraft is down in
relation to the left wing, then the roll angle is positive.
B. Implemented system
For every digital compass, it requires two types of sensor
to measure Heading, Pitch and Roll angle: accelerometer
sensor and magnetic sensor.
In this project, we use the HMC5883L [2] Sensor
Module to measure the Earth’s magnetic field in two axes
(x-axis and y-axis) and then determine the heading angle
with respect to the magnetic north. First, every fixed period,
the sensor board will send the value to Arduino Processor.
We call it raw value. Then a raw value sent to Arduino will
be converted to normalize the value. Because we don’t use
accelerometer sensor to measure for pitch and roll value, we
use the atan2 function to calculate the angle so it is
necessary to minus the offset to transfer the raw value to the
normalized value which will be introduced in below part.
The value after normalized is used to calculate the Heading.
The result is expected to show on Nokia 5110 LCD [4].
C. Block diagram
Components are divided into input, output, processor,
and power. The red block is the sensor board, which
measure the input. Then the input is sent to the blue block,
which is the processor of the compass. The data after
calibrated and calculated is now displayed in the gray block.
The blue block supplies the power for compass system.
pf3
pf4

Partial preview of the text

Download Digital Compass Using Arduino and more Papers Embedded Systems in PDF only on Docsity!

Digital Compass Using Arduino

Phuc Le Xuan^1 , Duy Nguyen Tien^2

(^1) Bach Khoa University, Affiliation 1, Ho Chi Minh City, Vietnam (^2) Bach Khoa University, Affiliation 1, Ho Chi Minh City, Vietnam Abstract — Human, for a long time, have been using a compass for applying in navigation. As information gathering becomes critical nowadays, it is necessary to have the tools to collect information about the environment. Orientation is key to understanding our location and interpreting data from that environment. The most reliable form of the determining orientation is through measurement of Earth’s magnetic field. In this paper, we will discuss how to design a digital compass using the magnetic sensor board and processing with the microcontroller on Arduino UNO board. Keywords — Digital compass, Arduino, Magnetic sensor board, LCD, Independent Vcc Source.

I. INTRODUCTION

Digital compasses have become popular in the past few years due to the advancement of magnetic sensors and feature-rich microcontroller. Compass applications have increased from simple, hand-help navigation devices to automobile navigation systems with voice recognition and up-to-date global maps. The digital compass is implemented via the Atmega328P-AU [3] microcontroller on an Arduino board and HMC5883L [2] sensor board... The values of magnetic field sending to the Arduino, where these values are mathematically processed to find the heading angle in degree which is the location of the North in degrees. The result then displayed on a Nokia 5110 LCD [4].

II. OVERVIEW

A. Compass Theory Basics Basically, to define one compass, we need three angles term these are popular within aviation industry: Heading, Pitch , and Roll. These angles are always referenced to the horizontal plane, which is perpendicular to Earth’s gravitational force. Where:  Heading : the angle in the horizontal plane measuring clockwise from a true north direction (1 o^ to 360 o ).  Pitch : the angle between an aircraft’s longitude axis (tail to nose) and the horizontal plane. For example, if the nose of the aircraft is pointed up, the pitch angle is positive.  Roll : the angle about the longitude axis between the horizontal plane and the actual flight orientation. For example, if the right wing of the aircraft is down in relation to the left wing, then the roll angle is positive. B. Implemented system For every digital compass, it requires two types of sensor to measure Heading, Pitch and Roll angle: accelerometer sensor and magnetic sensor. In this project, we use the HMC5883L [2] Sensor Module to measure the Earth’s magnetic field in two axes ( x-axis and y-axis ) and then determine the heading angle with respect to the magnetic north. First, every fixed period, the sensor board will send the value to Arduino Processor. We call it raw value. Then a raw value sent to Arduino will be converted to normalize the value. Because we don’t use accelerometer sensor to measure for pitch and roll value, we use the atan2 function to calculate the angle so it is necessary to minus the offset to transfer the raw value to the normalized value which will be introduced in below part. The value after normalized is used to calculate the Heading. The result is expected to show on Nokia 5110 LCD [4]. C. Block diagram Components are divided into input, output, processor, and power. The red block is the sensor board, which measure the input. Then the input is sent to the blue block, which is the processor of the compass. The data after calibrated and calculated is now displayed in the gray block. The blue block supplies the power for compass system.

Fig. 1 Block diagram of digital compass using HMC5883L sensor (GY- 271 board) a) GY- GY-271 [6] : the Compass Module is designed for low- field magnetic sensing with a digital interface and perfect to give precise heading information. This compass sensor fits into small projects such as UAVs and robot navigation systems. The sensor converts any magnetic field to a differential voltage output on 3 axes. This voltage shift is the raw digital output value, which can then be used to calculate headings or sense magnetic fields coming from different directions. Fig. 2 GY-271 board Table 1 GY-271 specifications: Characteristics Information^ Unit Microcontroller L Supply voltage 2.16 ~ 3.6 VDC I^2 C read address 8 bit I^2 C write address 8 Bit I^2 C rate 400 kHz Output rate 75 Hz Field range -8 ~ +8 gauss Digital resolution 0.73 ~ 4.35 milligauss b) Arduino UNO R3 SMD: The Arduino UNO R3 SMD [3]: a version of the Arduino Uno but it uses a surface mount version of the Atmega328P instead of the through-hole version. The board is based on the Atmega328. It has 14 digital input/output pins (of which 6 can be used as PWM outputs), 6 analog inputs, a 16MHz crystal oscillator, a USB connection, a power jack, an ICSP header, and a reset button. It contains everything needed to support the microcontroller; simply connect it to a computer with a USB cable or power it with an AC-to-DC adapter or battery to get started. Fig. 3 Arduino UNO R c) Nokia 5110 LCD Fig. 4 Nokia 5110 LCD board The Nokia 5110 [4] is originally intended to be used as a cellphone screen but now it is a basic graphic LCD screen applied in several applications. The module uses the PCD8544 [7] controller, which is a low power CMOS LCD driver, designed to drive a graphic display of 48x84 pixels. d) Software: In this project, we use Arduino IDE [8] software with the Adafruit_HMC5883_Unified-master [5] Library, Adafruit_Sensor-master [5] Library, the Adafruit_GFX [5] Library, the Adafruit_sensor Library to control the magnetic compass module; the Adafruit_PCD8544 [5] Library to control the Nokia 5110 LCD [4] board.

Fig. 7 comparing the result with iPhone No. B. Problem encounter and solution During of the project, we made some mistakes of buying wrong (or fake) sensor board and calibrating the raw data. The GY-271 uses HMC5883L sensor and L883 processor. But the first sensor board we bought is GY-273 which uses QMC5883L sensor and DA5883 processor. Then they could not be compatible with the hardware. At that time, we thought our fault was from the code. After many days configuring in hopeless, we bought the new board GY- and somehow it ran well but the results were not correct. We had to read all the datasheet of HMC5883L, create topics in the internet to find out that it is necessary to calibrate the raw data. C. Total Price Table 3 Cost of Components Component Price (USD) Arduino UNO R3 6 Nokia 5510 LCD board 2 GY-271 Sensor board 6 Making box 9 Battery 2 Other components (Switch, wire...) 5 Total price 30 Because this is the research project, the cost of the compass is hyped. If we make this compass become the commercial product, all of the component can be replace by cheaper ones. The out-the-door price is about 15 dollars, which 50% equals to the research price.

V. CONCLUSION

In this paper, a low-price and simple digital compass has been introduced. Because this is a magnetic compass, so the magnetic material, magnetic field, metallic surface or motors probably make the measurement go wrong because of the magnetic interference. To get a decent result, make sure to put the compass on a flat surface and be away from the magnetic object.

ACKNOWLEDGMENT

We would like to thank Assoc. Prof. Tin Thanh Dang for all your supporting and advising us all the time to finish this project. This work is supported by the Faculty of Electrical and Electronics Engineering, Ho Chi Minh City Bach Khoa University, Vietnam.

REFERENCES

Compass theory at https://en.wikipedia.org [1] About HMC5883L at https://www.sparkfun.com/ [2] About Arduino UNO at https://www.arduino.cc [3] NOKIA 5110 LCD at https://www.sparkfun.com/ [4] Library for software - https://github.com/ [5] GY-271 ELECTRIC COMPASS DESCRIPTION at http://www.robotpark.com/image/data/PRO/91457/GY_271_EL ECTRONIC_COMPASS.pdf [6] PCD8544 Information at https://www.sparkfun.com/ [7] Arduino IDE software at https://www.arduino.cc/ [8] Serial Print - https://www.arduino.cc/en/Serial/Print [9] Microsoft Office - https://www.microsoft.com/ Author: Phuc Le Xuan^1 , Duy Nguyen Tien^2 Institute: Bach Khoa University Street: 268 Ly Thuong Kiet City: Ho Chi Minh Country: Viet Nam Email: [email protected](1) [email protected](