PIC Fuel Consumption Monitor. Updated Apr 2007 Back to my Home Page

 

See more photos.

 

For Cars:

Connect a fuel sensor (available from Radionics in Ireland www.radionics.ie, stock code 256-225,) and the car's milometer/speedometer (outputs distance pulses) output to a 16C84 PIC device. The Fuel rate, distance travelled per unit of fuel used, time of journey, distance travelled, fuel used, fuel flow rate is displayed on a Hitachi LM032 LCD display. Here are some photos of the hardware. (updated Sep 2003). Here is the circuit diagram (updated Sep 2003). Note that The PIC is clocked at 4MHz, the oscillator componts have been ommitted from the circuit diagram.

The fuel units are in pulses from the fuel sensor. I noted approx 1000 pulses = 1 liter. Distance units are in speedometer pulses. So if you want the display to show Liters and Kilometers etc you will need to modify the software to accomodate your particular fuel sensor and car speedometer. Use the divison routines in the file dbl_divs.asm. Time is measured in seconds.

Notes on the circuit diagram:

Power is taken from the car's 12volt supply. It is then regulated to 5volt. The speedometer pulses from you car are more than likely 0 to +12volt. D2 is any small signal diode and prevents the +12 Volt pulses from bringing Port B input B6 higher than 5volt.

The LCD display is a Hitachi LM032L. On initialisation the PIC software sets the data mode to 4 bit (instead of 8) so that LCD data lines DB0 to DB3 are not used.

D1 is any power diode rated at 1 Amp and prevents damage to the PIC etc if the polarity is accidentally reveresed. Any 5V regulator will do, the current consumption of the PIC/LCD/Fuel sensor is low.

For carburettor engines the fuel sensor is placed in the fuel line leading to the carburettor fuel inlet. I have not tried it on a fuel injection car. If you're not sure then seek the advice of a mechanic.

Port A3 can be connected to a seaker circuit. A beep is sounded whenever the unit is powered up. As that's all it does you can leave out the speaker.

Other Applications:

This project could of course be used in other areas: e.g. boats, central heating etc. Anywhere situation where you want to measure fluid used and fluid flow rate and fuel used per distance travelled. In a boat the fuel sensor can be fitted as above and to get 'distance' pulses you can probably use the output from the boat's distance meter e.g. Garmin Fishfinder depth guage can have a speed sensor fitted and I'm sure the output if the speed sensor would also be distance pulses to represent distance travelled over water.

 

PIC 16C84 Source files:

main.asm Main program. Initialises everything and then falls into Main loop. Also handles interrupts e.g. when the fuel sensor pulse occurs it causes an interrupt. The fuel sensor interrupt calls a routine that increments a 16 bit counter. Distance is counted the same way and the main loop divides distance by fuel used and displays this on the LCD LM032 display.

The main loop looks like this:

MainLoop
Call DisplayDistance ; Display cumulative distance
Call DisplayFuel ; Display cumulative Fuel
Call DisplayTime ; Display elapsed time
CallWPosCurs, MPGposn ; Position LCD Cursor
Call PrintMPG ; Calculate and print MPG
call HandleButtons ; Check/process any buttons pressed
goto MainLoop

 

eelib.asm EEPROM routines. General purpose routines to read, write, clear, increment EE ram locations in the 16C84 PIC device

lcd.asm & lcd.inc LCD Driver - for Hitachi displays, supports 4 and 8 bit data path (by changing a flag setting). Configurable for displays with different numbers of lines and number or characters in a line. 4 bit data path is used in this application due to the limited I/O of the PIC 16C84.

library.asm Library - Miscellaneous routines. Wait timer routines. Speaker Toggle, Warble sound. Clear ram.

dbl_divs.asm Double precision floating point division - Modified version from Microchip library. The Microchip routines used fixed ram locations for Denominator, Numerator, Result and remainder - so I modified the routines so you can change these locations for better reuse of limited ram locations.

macros.inc Miscellaneous macros including: Move Hi nibble of W to Hi nibble of File and other nibble manipulation routines, Load W register with literal and call function, Move 16 bit files to 16 Destination file, Play tone with specified frequency and duration.

messages.asm All messages for display are in this source file for easy maintenance and/or translation into other languages.

p16cxx.inc Standard Header File, Version 2.04 Microchip Technology, Inc.

 

Note that the source files developed by Karl Grabe are in the public domain but cannot be used for commercial purposes without permission.

Disclaimer:

You use the circuit, software, fuel sensor information and ideas presented here at your own risk! Karl Grabe does not accept any responsibility for any inconvenience, damage or personal injury caused by the information supplied here. Ensure proper safety procedures are adhered to when working on your car especially with fuel..