Code Monkey home page Code Monkey logo

avr-flight-fuel-timer's Introduction

Light Aircraft Fuel Timer

This is a small (completely overkill) embedded project for monitoring fuel while flying small aircraft like the Cessna 172, Piper Warrior, etc. It's currently written against the Atmel AVR ATMega328P microcontroller, though the plan is to eventually use the ATXMega128D4.

I have some practical use for this, but it's mostly an experiment in how much UI can be crammed onto a medium-sized 8-bit micro.

More project info can be found on the project page on Hackaday.io.

Building

This project is set up for develop on Linux and OSX. It can probably be made to work under AVR Studio on Windows with some work. It currently needs to be built using -std=gnu99. The target is expected to run at 16MHz, but CLOCK can be configured in the Makefile to whatever suits your fuses.

On a Debian-based Linux distro:

# Install build and flashing tools
sudo apt-get install gcc-avr avrdude binutils-avr

# Install Python if you don't already have it for some reason
sudo apt-get install python python-pip

# Install the PyYAML module (required for some code generation)
pip install pyyaml

# Build the project
make

The test suite can be run using:

# Grab testing library
git submodule init
git submodule update

# Run tests
make test

Flashing a device

avrdude options for your programmer can be specified with PROGRAMMER:

# Flash a device connected via serial with an Arudino bootloader
make flash PROGRAMMER="-c arduino -P /dev/ttyUSB0 -b57600"

# Flash with an AVR Dragon programmer in ISP mode
make flash PROGRAMMER="dragon_isp"

Notes for users

  • Fuel and fuel burn per hour are represented as whole integers. Partly because this device is for approximation, and partly because the precision of a fuel tank dipstick or a "fuel burn per hour" average/max is unlikely to be greater than whole numbers.

    If you want better accuracy, get avionics that have a digital fuel flow meter and fuel level sensors that can work out your actual burn and endurance.

Developer notes

  • Strings are stored in PROGMEM (__flash under gnu99). These are defined in text.yml and turned into C header and source files during build, as the C code to ensure reuse of strings in flash is verbose and repetitive.

  • There is no dynamic allocation in this project. This design choice is partly to avoid hard to reproduce bugs that are possible with heap allocation on microcontrollers, and partly as a fun challenge.

  • State exists statically in a few places (eg. system.c). Global variables are avoided in favour of private state with an exposed interface. Functionality is defined independently of this state where possible (eg. eventloop.h).

  • An event loop is currently used to handle user input. This is an experiment and is a bit limited (no arguments, small event queue, etc). Not entirely sure this is appropriate for an embedded device, but it's nice to work with for now.

  • This is my first pure C project. There may be oddities because of this - feedback is appreciated.

Schematics / hardware

Details coming in future on how to put this circuit/device together. Currently this is sitting on a breadboard on my desk.

avr-flight-fuel-timer's People

Contributors

stecman avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

aeroworks

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.