Git Product home page Git Product logo

wmm_tiny's Introduction

WMM_Tiny

This is a small embedded C99 implementation of the World Magnetic Model published by NOAA for calculating the magnetic field at any point on the world's surface for a given date in the years 2020 to 2025. This implementation uses the latest coefficients from NOAA for the years 2020 to 2025.

This implementation is a cut down version of the source code supplied by NOAA and is intended for small embedded systems. The limitations are:

  • Calculates magnetic variation only

  • Only calculates the magnetic variation at altitude zero relative to the WGS84 ellipsoid, which is approximately the Earth's surface

  • Uses floats in its calculations, not doubles. This will reduce accuracy very slightly.

  • Stores the coefficients in a compressed format. The floating point coefficients are converted to fixed point floats and then stored as scaled variable length signed integers.

The intention of this project is to reduce the code space as much as possible at the expense of RAM. This makes it suitable for small embedded processors short on code memory but with 4.2 kBytes of RAM available. The coefficients are compressed in code but are expanded back into their normal format in RAM when the code runs.

This example project is for the STM32F103C8 processor and a project is supplied for the STM32CubeIDE. However, the WMM part of the code is written in standard C99 and can be ported to other processors easily. The files necessary for porting are these:

Core/Inc/wmm.h

Core/Src/wmm.c

Core/Src/WMM_COF.c

Doxygen style documentation of the API is found in wmm.h. Example code calling the API is found in Core/Src/main.c.

This code requires 4.2 kBytes of RAM permanently. All memory is statically allocated.

The source code may look a bit strange to a seasoned C programmer with gotos in the code. This is because this is a port of the WMM souce code provided by NOAA which is itself a port of the original WMM code written in Fortran.

Under folder wmm_cof_converter is a sub-project that compresses the coefficients file supplied by NOAA (WMM.COF) to a C99 source file that is used by the WMM_Tiny project (WMM_COF.c). Included is the version of WMM.COF current at the time of writing but you should check on NOAA's website for a later updated version and regenerate WMM_COF.c if a later version is available. This sub-project also has project files allowing it to be loaded and built in STM32CubeIDE or the single C99 source file wmm_cof_converter.c can be compiled by any C99 compiler.

The original code was developed by NOAA / NCEI.

https://www.ngdc.noaa.gov/geomag/WMM/

wmm_tiny's People

Contributors

miniwinwm avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.