STM32 Primer2 Design Competition 2009


Locus – A GPS extension for Primer2

2009-06-21

Johannes Layher

Contents

1 Abstract...... 1

2 Purpose of document...... 2

3 Introduction...... 3

3.1 Objectives...... 3

3.2 Requirements...... 3

3.2.1 Hardware...... 3

3.2.2 Software...... 4

4 Basics ...... 5

4.1.1 GPS ...... 5

4.2 NMEA ...... 5

4.3 UTM system...... 5

4.3.1 What is UTM?...... 5

4.3.2 How to convert Latitude / Longitude to UTM?...... 6

4.4 Logging data format ...... 6

5 User Guide...... 8

5.1 Requirements...... 8

Locus is developed for CircleOS 3.7 and supports Primer2 only...... 8

5.1.1 Installation...... 8

5.1.2 SD-Card...... 8

5.1.3 GPS module...... 8

5.2 Usage...... 9

5.2.1 Splash screen...... 9

5.2.2 Toolbar...... 9

5.2.3 GPS data screen...... 9

5.2.4 GPS details screen...... 10

5.2.5 About screen...... 10

6 Design Documentation...... 11

6.1 System Overview...... 11

6.2 Hardware...... 12

6.2.1 Locus extension board...... 12

6.3 Software...... 13

6.3.1 Architecture ...... 13

6.3.2 Detailed Module Description...... 14

6.4 Development Environment...... 14

7 Conclusion...... 15

7.1 Work in Progress...... 15

7.2 Final Words...... 15

8 Symbols and Abbreviations...... 16

9 Bibliography and Links...... 17

10 License...... 18

1

1Abstract

This CirleOS application and hardware extension for Primer2 provides means for showing the current location and logging this data.

Standard Longitude / Latitude information and other GPS data is provided on the LCD as well as precise coordinates based on the UTM/MGRS system.

Logging means saving the current location to retrieve this data later on. This is achieved by saving the position formatted as GPX file on the SD-Card memory.

2Purpose of document

The first parts of this document are referred to as the user guide section. It describes how Locus is used what it features and how the user is to interact with it.

The second part is the design documentation. It describes how Locus is developed, how the software is implemented and what limitations apply.

3Introduction

In living memory mankind had means of navigation. Finding and describing “places” started with the aid of notably natural realities. One can imaging that simple descriptions as “down by the river” or “at the big tree on a hill” preceded absolute directions and navigation with the aid of sun, moon and stars. Gyro and magnetic compasses made directions available at any time, independent of the stars. And nowadays satellite based navigation widely known as GPS gives not only directions but precise location information of a place.

And this is the simple origin of the project's name: “Locus” is Latin for “place”.

3.1Objectives

The aim is a device capable of logging and showing position data.

Well, buying a device is not like building a device yourself. Therefore it was clear for me to develop a mobile GPS device. Why not use Primer2, it got all it needs:

  • An UART interface at the extension slot for connecting a GPS module.
  • A display for showing the current location.
  • SD-Card support for data storage.
  • USB interface for connecting to a PC and retrieving all logged data.
  • Audio recording and playing, to append information to locations.
  • Internal temperature sensor

3.2Requirements

Supporting all Primer2 features and possibilities with an attached GPS module in a single application is quit a challenge, so this project shall fulfil only these requirements:

  • Display the current location Latitude / Longitude in degrees among other GPS based information
  • Show the current coordinates based on the UTM/MGRS system
  • Save the location data to retrieve this later on by using a common data format
  • Support waypoints as a marking for special locations

3.2.1Hardware

The introduced requirements depend on these hardware features of the Primer and its additions:

  • GPS module
  • UART interface
  • SD-Card
  • Display and buttons
  • USB connection for retrieving the data log

3.2.2Software

The defined hardware depends on some software drivers. These requirements apply to the software part:

  • UART driver
  • SD-Card driver with file system support
  • Display routines
  • USB support for accessing files save on SD-Card

Luckily CircleOS provides basic access to a SD-Card and its file system. Furthermore USB mass storage is support directly, too.

Besides the hardware related software (drivers) the listed entries below are the essential parts of the Locus application:

  • Generic application handling
  • Evaluation of the GPS data
  • Conversion of Latitude / Longitude to UTM coordinates
  • Data conversion for saving as GPX file

4Basics

This section covers some basics applicable to Locus.

4.1.1GPS

GPS is a satellite based positioning system. About 32 satellites are transmitting time stamps which a GPS module receives. Different runtimes among the data transmissions of multiple satellites are used to calculate the position information. Refer to [1] for more details.

4.2NMEA

NMEA in this case refers to NMEA-0183 which is a data specification. Most of the GPS modules available support NMEA-0183 format. It specifies (besides the electrical part) how positioing information is formatted and thus provided by the GPS modules.

A simple data entity – a so called NMEA sentence – is the basic RMC sentence (recommended minimum data for gps). It has the following structure:


Among other information it encodes the time, GPS data status, Longitude, Latitude and date. All is secured by a checksum. For more details refer to the GPS module documentation [13], or [15], [16].

4.3UTM system

This maybe is the least out-standing feature of Locus. It is just a few numbers. But implementing a Lat/Lon to UTM conversion is quite challenging.

4.3.1What is UTM?

UTM (Universal Transverse Mercator) is a coordinate system to describe locations on the surface of the earth by using a grid system. This grid divides the earth into several zones (longitude) starting with zone 1 at 180 degrees west to zone 60 at 180 degrees east. Furthermore there are 20 so called bands (for latitude) starting from A, B at 80 degrees south to Y, Z at 84 degrees north (letters ‘I’ and ‘O’ are omitted).

So for example Berlin is in zone 32U (where 32 is the zone and U is the band reference).

The zone itself is now referenced; to give a reference of a certain location within the zone distance offsets in metre are given. For more details refer to [5], [6].

4.3.2How to convert Latitude / Longitude to UTM?

Conversion of latitude and longitude, as provided by most GPS modules via NMEA sentences, to UTM coordinates is basically a transformation of a coordinate systems.

In short this is really heavy math leading to an algorithm with lots of floating point trigonometric calculations [15].

4.4Logging data format

The format for data logging could have been the raw NMEA sentences received from the GPS module. But NMEA does not support waypoints.

Therefore one of the common GPS file formats is needed which supports waypoints and which is not too difficult to implement. I chose GPX as it supports simple tracking for several GPS data entries.

The XML based GPX files follow this structure:


As can be seen all entries are of the “wpt” type, which is a waypoint. The waypoints that can be set using locus by pressing the waypoint button are marked different in the additional “name” field.

So the first and the last entry in the example file are just normal waypoints (or trackpoints) saved every update cycle, the name is “TRK00000001”. The middle waypoint with the name filed stating “WPT00000001” is such a generated waypoint. That is the only difference.

For direct evaluation, GPX files are suported by Google earth, and the almighty GPSbabel [17]. Example GPX files and the standard can be found on the topografix homepage [18].

5User Guide

This section describes how the Locus application can be used.

5.1Requirements

Locus is developed for CircleOS 3.7 and supports Primer2 only.

5.1.1Installation

As Locus is standard CircleOS application the procedure defined by CircleOS for installing applications apply.

Generally the provided object file (in case of Locus a library file!) can be added to the Primer2 flash by using the add_CircleOS_application.bat. For more information refer to the CircleOS documentation [19].

5.1.2SD-Card

For saving the GPS position information a SD-Card memory is needed. Locus only saves a file to the SD-Card memory if a folder named “locus” has already been created in the root directy. Otherwise Locus will not creat any files.

Unfortunately CircleOS 3.7 currently does not support creation of directories, therefore there is no possiblity for the Locus application to create one autoamtically.

Locus has been tested for SD-Card memories up to 2GB capacity.

5.1.3GPS module

A GPS module is needed to provide the GPS position information. It is connected to the UART provided on the extension header and uses a data rate of 9600 baud.

Currently only the RMC and the GGA NMEA sentences are supported.

But Locus should work with every GPS modules supporting these requirements.

5.2Usage

5.2.1Splash screen

A simple splash screen shows up after Locus has been launched from the CircleOS menu. After a few seconds it vanishes and the first screen page is displayed.

5.2.2Toolbar

Locus is controlled by the toolbar buttons.

Item / Button / Description
1a / / Start recording of tracklog. (GPS position information is saved to the SD-Card). The button then changes to item 1b.
1b / / Stops recording of a tracklog. The button changes back to 1a.
2 / / Saves a waypoint to the tracklog. (only possible if a track recording is running)
3 / / Cycles to the next screen page.
4 / / Quits locus if pressed again.

5.2.3GPS data screen

This screen shows the basic position information.

Item / Name / Description
1 / ZON / The UTM zone with the MGRS Band information, e.g. 32U
2 / NRT / The UTM northing value in [m]
3 / EST / The UTM easting value in [m]
4 / LAT / The Latitude in [°]
5 / LON / The Longitude [°]

5.2.4GPS details screen

Some more GPS information is shown

Item / Name / Description
1 / ALT / Current altitude. Although not quit correct, it is the geoid height.
2 / COR / Current couse of movement in [°]
3 / SPD / Current speed of movement in [m/s]
4 / DAT / Current date
5 / TIM / Current time

5.2.5About screen

The about screen just shows the Locus version and author information.

6Design Documentation

Description of the Locus software architecture and the hardware extension board follows in this section.

6.1System Overview

A short system overview of the Locus application an its environment:


Item / Name / Description
1 / GPS satellites / These are the GPS Satellites transmitting the GPS data.
2 / Primer2 / The Primer 2 provides the user interface with LCD, Buttons and Audio, and the extension header for connecting the GPS Module.
3 / GPS Module / The NAVILOCK NL-504ETTL GPS module is a GPS data receiver. It is based on the MediaTek MT3318 Chipset. It is connected via the extension header to the UART interface.
4 / Locus / The Locus application provides GPS data evaluation and shows this data on the display. The position information is saved to a SD-Card.
5 / CircleOS / CircleOS is the underlying operating system providing high level drivers for the supported periphperals (LCD, Buttons, SD-Card, etc.)
6 / User / The Locus user.

6.2Hardware

This section covers the hardware features of the Primer2 and Locus extension board. All used components are illustrated in the figure below:

6.2.1Locus extension board

The Locus extension board consists of a GPS module and a simple power switch with a P-channel MOSFET. Refer to the schematic below:


Attaching the GPS module to the Primer2 is pretty simple. Mind the switching of RX/TX lines.

The GPS module is not specified to 2.8V of the Primer2 therefore it needs a separate power supply which is directly taken from the VBAT. Therefore the P-channel MOSFET is used to enable/disable the GPS module.

The following table is the according BOM.

Item / Identifier / Description / Quantity
1 / X0 / Primer2 Power Jumper (VBAT, JP3 [13]) / 1
2 / X1 / Primer2 Extension Connector (JP2 [13]) / 1
3 / R0 / Pull-up 470k Ohm / 1
4 / Q0 / IRF7314 P-Channel MOSFET / 1
5 / M0 / Navilock NE504-TTL GPS module / 1

6.3Software

6.3.1Architecture

Locus is based on Primer2 with CirclOS. Therefore it must comply with the basic architecture for CircleOS applications.


6.3.2Detailed Module Description

For a detailed description on the modules and the specific way of implementation refer to the online documentation generated with doxygen.

6.4Development Environment

The Development environment consists of Locus itself, naturally Primer2 and the Raisonance toolset. A short overview of all tools in use follows in the table below:

Item / Manufacturer / Link / Software / Version / Description
1 / / eclipse / Galileo RC2 (win32) / IDE for software development and module tests
2 / / RKit ARM Software Toolset / 1.20.09.0154 / Compiler, Linker, Debugger
3 / / Ride7 / 7.20.09.0162 / IDE for debugging
4 / / doxygen / 1.5.9 / Source code documentation
5 / / GraphViz / 2.22 / For diagrams generated by doxygen
6 / / OpenOffice / 3.1 / Documentation
7 / / INKSCAPE / 0.46 / Graphics for Locus (Toolbar, Logo)
8 / / KiCad / 2008-08-25c-final / Schematic, PCB Editor

7Conclusion

7.1Work in Progress

There a lot of things on my mind. Some ideas I could not include into Locus, some ideas that would have been too time consuming during contest period. This unsorted list should give a rough idea:

  • Add initialisation for the GPS module to adjust NMEA sentences, update rate and communication baudrate.
  • Improve NMEA data evaluation, decode more sentences and write.
  • Write more data (if evaluated from NMEA sentences) to the GPX logfile.
  • Add voice recording for additional audio information (cartography notes for e.g. openstreetmap).
  • Eye candy for the display screens!
  • Increase device uptime by using external LiPo cells.
  • Find a suitable GPS module running at 2.8V (simplify, stabilize and improve hardware design).
  • Change data log access from USB mass storage to a dedicated vendor specific interface including drivers for Linux/Windows and an appropriate application for log data evaluation (omit using the FAT file system access to SD-Card in raw mode).
  • Provide a better file system for SD-Card like YAFFS, JFFS(2).
  • Develop an embedded map rendering-engine for directly using operstreetmap data files.
  • Develop an embedded map rendering-engine for directly using garmin compatible data files.

7.2Final Words

I would like to make very clear that this project is not my genius development alone. All the GPS interfacing (NMEA sentence processing) and UTM conversion has been developed by me but for correct usage of the CircleOS features I had deep looks into other CircleOS Applications:

Hence I want to give credit to:

  • sjoerd for SDCard Explorer 1.1 and USB Mass storage 1.1 (SD- Card access)
  • yrt for Dictaphone 1.0 (audio handling, SD-Card access)

8Symbols and Abbreviations

Symbol / Abbr. / Definition / Description
GPS / Global-Positioning-System [1]
GPX / GPS Exchange Format [2]
NMEA / National Marine Electronics Association [4]
UTM / Universal Transverse Mercator [5]
MGRS / Military Grid Reference System [6]
FAT / File Allocation Table [7]
YAFFS / Yet Another Flash File System [8]
JFFS / Journaling Flash File System [9]
LiPo / Lithium-ion polymer battery [10]
LCD / Liquid crystal display [11]
USB / Universal Serial Bus [12]
BOM / Bill-Of-Material

9Bibliography and Links

[1]

[2]

[3]

[4]

[5] ...

Transverse_Mercator_coordinate_system

[6]

[7]

[8]

[9]

[10]

[11]

[12]

[13]NL_60412_-_Datenblatt_MTK_GPS_Module_24092007_480.pdf (0.9)

[14]STM32-Primer2_V1.1, STM32-Primer2 schematics (last updated 14/11/2008)

[15]

[16]

[17]

[18]

[19]Application Note AN0054: CircleOS Tutorial for STM32-Primer2, Document version 2009-01-16

10License

This software, the provided hardware schematic and information in this document in general comes with absolute no warranty.

If not prohibited by the Raisonance design contest this work is distributed under the following license: