Diesel engine fuel flow rate pulse generator

I have a device that accepts pulse inputs, translates them into a digital rate (pulses per second), and then outputs the results in NMEA 2000 format (NMEA 2K is a standard for marine data networks). One example use is to connect it to a tachometer, which generates a pulse with every engine revolution. The device listens to the pulses, converts the pulse rate to a digital value, and sends the data out to NMEA every second or so.

The application I want is to measure the fuel flow rate. There are super-cheap flow meters that generate a pulse train (from 0V to whatever the supply voltage is -- say +5V or +12V). Great -- all I do is connect the flow meter to my gizmo, and I can send fuel flow readings to the NMEA network. My gizmo will accept anything up to 24V pulses, btw. But wait -- there's a problem. A diesel engine has two fuel lines. One goes from tank to pump to injectors, and the other goes from injectors back to the tank. Why? because the fuel pump's job is to deliver as much fuel as the engine could possibly want. Whatever the injectors don't use goes back to the fuel tank. So if you use a single flow meter, you don't get the actual fuel consumption. To get that, you have to subtract the return flow from the supply flow.

My gizmo doesn't do subtraction. It just want a train of pulses, and converts the pulse frequency to a number. Just one pulse train.

Enter Arduino. I want to connect the supply line flowmeter to one pin on the Arduino and the return line flowmeter to another pin. Now I want the Arduino to subtract the count on the return line pin from the count on the supply line pin and generate a pulse stream equivalent to the difference. For example, if in a time period T the Supply line pin registers 75 pulses and the Return line pin registers 23 pulses, I want the Arduino to generate a pulse stream of 52 pulses per T. So if T was one second, the Arduino would generate 52 pulses per second. Every second, the Arduino would redo the calculation and adjust its rate for the next second.

Of course, I want T to be as short as possible so that my system will detect changes in flow rates very quickly. But it doesn't have to be insanely short -- maybe 10 times per second.

I am an experienced programmer, but I have never touched an Arduino. I have done some circuit-building (made a little line-following robot, e.g.).

I have seen a few forum discussions that talk about counting input pulses, but nothing exactly like this. BTW, my Arduino doesn't have to do anything else. A one-trick pony.


You might try a different approach by evaluating each injection pulse to the fuel injectors. Depending on conditions the injectors are injecting a specific amount of fuel into the engine at a rate proportional to engine rpm and load. I think now some cars have mpg apps that measure fuel consumption vs wheel rpm to generate real time mpg values. If your engine has mechanical injectors then a more mechanical method might be used.

Your differential flow rate project sounds very feasible, but you need to evaluate what zoomkat said about the alternative of injector pulse counting if you have some way to pick that up.

Reading the flow meters with interrupts and determining the difference in counts is pretty standard.

Do you have the details on the supply and return flow rates at idle and full throttle, and what the two flow meter counts would be at those values? I'd like to get a sense of the range of pulse frequencies you want to send as that might determine what you want to do for the output.

There are several different methods and possible timer libraries you can use to send the output square wave pulse train.

In particular, there are some very easy to manage square wave generation tools on the Arduino using either the core tone() function or the tone library which use the hardware timers, but let you avoid direct low level hardware timer management.

You can also easily write software timers based on the millis() or micros() time functions which you can use to send a square wave by toggling an output pin at a given rate.

With either hardware or software timers, I doubt there would be an issue with changing values every 100ms, as the 16mhz processor is pretty fast on that scale.

If you're lucky, one of the hardware gurus on the site can also come up with a recommendation for a chip which takes the two inputs and outputs the difference. You might not even need the Arduino, but what's the fun in that.

I have a diesel engine in a boat and I am interested in this. Can you post a link to the datasheet for the flowmeter you propose to use ?

What is the price of the flow meters? So far I have not come across any that would be cheap enough as well as accurate at very low consumption. My engine consumes about 1 litre per hour when just driving the alternators. I would like to get the best bang for my buck when charging, which would mean measuring variations of (say) 0.1 litres per hour or less.

My engine has no electronics.

The programming to subtract the two fuel flows will be straightforward. Count the two pulse streams over a reasonable time period and then subtract the small count from the big one.


There is a great variation in the design of fuel systems for Diesel engines.

My Kubota tractor has only a single fuel line from the tank to the injector mechanism. No return line.

My old Dodge pickup has two fuel lines, as noted earlier, and a mechanical injection device. One fuel injection pulse at a time.

My 2013 VW Jetta TDI also has two fuel lines, but electronic injection that may do several injections on one firing when under load.

So, don’t generalize when designing a fuel usage system.


Interesting discussion, deriving data from fuel flowmeters onboard vessels is something we're working with daily. Nowdays we're doing this by making use I/O materials (Beckhoff modules), although we're looking for alternatives.

@ Leighwebber, what kind of flowmeters are you exactly talking about?

The basic system layout we're looking for is as follows

BASIC SYSTEM LAYOUT: Connect up to two individual flowmeters (with each one pulse transmitter & temperature sensors) to a hardware device and transfer the data by ethernet (nmea 0183) to a central datalogger.

SPECIFICATION PULSE TRANSMITTER: Type Omnipolar Hall Switch Max. supply volts 24V (at 150°C) Max. supply current 9 mA Internal resistance 3,4 kOhm (1k2 serial, 2k2 pull-up) Pulse output Active, pulse level depends on total circuit resistance* Wire colour red (24 V sensor supply), black (gnd) , yellow (pulse) The number of pulse depend on the size/type of the meter and do vary between 5 P/L up to 160 P/L

SPECIFICATION TEMPERATURE TRANSMITTER: Type PT100 Temperature range as indicated on the instrument text plate Wire colour Brown (PT100-1), Blue (PT100-2), White (PT100-sense

What do you think is this comparable to your project? Maybe we can team up to solve our common challenge.

@Enno, what is the price of the sensors you are using ?


@Robin2, those price varies between 1500-3500 EUR depending on the flowrate (160-500 l/min). Looking at your previous comment, the one's we're using aren't suitable for your application. Maybe you can find someting with maretron (http://www.maretron.com/)? Accurancy is indeed an issue.

Since the return flow is lower than the forward flow, you can pass the forward pulses (on another output pin), except every next pulse when a return flow pulse arrived.

Enno: @Robin2, those price varies between 1500-3500 EUR

Thanks for the info.

I would need to save a lot of diesel to justify those prices. :)


Anyone, considering a fuel consumption monitoring system should check the mass-flow fuel-flow sensors. These have a double sensor for flow and return-flow and do all the math for you, giving pulses that are 1:1 ratio with real consumption. They cost around € 300,-

If you know rpm and throttle opening, can't you infer fuel consumption?

Just a thought.....


allanhurst: If you know rpm and throttle opening, can't you infer fuel consumption?

No. Even if you have a precise concept of "throttle opening" the amount of fuel delivered will vary with wear and tear.

And on my engine throttle position is a very vague concept, as well as which it has a governor so the throttle lever really regulates engine speed, not fuel supply.


I was working on something similar for a VW TDI. Ended up going with a trip computer upgrade which was under the price of a 2way flow sensor.

as mentioned above, it had a send and return and multi-stage injection.

You could go off the throttle or airflow sensor, but these are only an estimate. But from what I tell the VW trip computer is only an estimate, that overall averages out to fairly accurate ~

The instantaneous is awfully slow to react.

using the cheaper flow sensors you find, id think the difference in vs out would be so small it might almost go un-noticed?

Hi, I skimmed through this thread, can you tell me the Make and Model of the engine? I work for Cummins.

@ leighwebber did you ever complete this project? I am doing the same on my boat right now but have code trouble. maybe you can help?

Most cars these days are using the injectors themselves to measure flow rate of fuel - you could look into that .

The problem with metering the flow is the feed side runs at a high pressure and a “ cheap” meter won’t cut it . Also , due to the injectors, flow rate is pulsing , which most meters don’t like

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.